Skip to content

Commit

Permalink
Issue ivanstegic#10: simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
munirahmed007 committed Jan 23, 2021
1 parent 8035cb1 commit 71aa8b8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Menu Bar DNS/Menu Bar DNS/DNSConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ class DNSConfiguration: NSObject {
}

if let dhcpValues = dynamicPlist?[kSCPropNetDNSServerAddresses] as? [String] {
var allDHCPStr = dhcpValues.joined(separator: "\n")
allDHCPStr = allDHCPStr.appending("\n")
let updatedDHCPValues = allDHCPStr.replacingOccurrences(of: "\n", with: "(via DHCP)\n")
var allDHCPValues = updatedDHCPValues.components(separatedBy: "\n")
allDHCPValues = allDHCPValues.filter({ $0 != "" })
allDNSIPAddresses += Array(Set(allDHCPValues))
let uniqueValues = Array(Set(dhcpValues))
for dhcpValue in uniqueValues {
let newvalue = dhcpValue.appending(" (via DHCP)")
allDNSIPAddresses.append(newvalue)
}
}
return allDNSIPAddresses
}
Expand Down

0 comments on commit 71aa8b8

Please sign in to comment.