I tried using "Reachability" class to check whether my network connected to LTE or Wifi in Swift but i am not able to get the solution.I have created a Mac OS application and added Reachability class. Now i have to check whether my network is Wifi or Cellular(4G, LTE).is there a way to find this?Iam using SystemConfiguration framework and "isWWAN" always returns false.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I am using the below code snippet to get the system preferences firewall status wheter it is ON/OFF using system .plist file.func getFirewallStatus() -> Bool {
let paths = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .systemDomainMask, true)
var path = paths[0]
path = "\(path)/\("Preferences/com.apple.alf.plist")"
path = path.replacingOccurrences(of: "/System", with: "")
let _dictionary = NSDictionary(contentsOfFile: path)
// firewall status
let status = (_dictionary["globalstate"] as? NSNumber)?.intValue ?? 0
if status == 0 {
return false
}
return true
}Sandbox disable(Xcode): In this case, I am able to get the firewall status (On/Off).Sandbox enable(Xcode): app is crashing when accessing the contents of file.let _dictionary = NSDictionary(contentsOfFile: path)Please let me know the reasons, why app is crashing in case of sandbox enable mode?My intention is to get the status of firewall and not to update any system preferences config.Thanks in advance!