cs5530 mobile wireless systems
play

CS5530 Mobile/Wireless Systems More on Swift Yanyan Zhuang - PowerPoint PPT Presentation

CS5530 Mobile/Wireless Systems More on Swift Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang UC. Colorado Springs CS5530 Ref. CN5E, NT@UW, WUSTL Overview Optional WiFi interface Location manager


  1. CS5530 Mobile/Wireless Systems More on Swift Yanyan Zhuang Department of Computer Science http://www.cs.uccs.edu/~yzhuang UC. Colorado Springs CS5530 Ref. CN5E, NT@UW, WUSTL

  2. Overview • Optional • WiFi interface • Location manager CS5530 2 Ref. CN5E, NT@UW, WUSTL

  3. Optionals • Some variables (other than vars or constants) either have a value, or nil • To define an optional o var optionalFloat: Float? • Optional with forced unwrapping CS5530 3 Ref. CN5E, NT@UW, WUSTL

  4. WiFi interface • interfaces = CNCopySupportedInterfaces() o Return all the available interfaces on your device (e.g., en0) o As an array • interfaceInfo = CNCopyCurrentNetworkInfo(interfaces) { BSSID = "6c:f3:7f:ea:44:f1"; SSID = "UCCS-Wireless"; SSIDDATA = <55434353 2d576972 656c6573 73>; } CS5530 4 Ref. CN5E, NT@UW, WUSTL

  5. WiFi interface • ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String o UCCS-Wireless • bssid = interfaceInfo[kCNNetworkInfoKeyBSSID as String] as? String o 6c:f3:7f:ea:44:f1 CS5530 5 Ref. CN5E, NT@UW, WUSTL

  6. Code example func getSSID() -> String? { var ssid, bssid, info: String? if let interfaces = CNCopySupportedInterfaces() as NSArray? { for interface in interfaces { print(interfaces) if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? { print(interfaceInfo) ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String bssid = interfaceInfo[kCNNetworkInfoKeyBSSID as String] as? String info = ssid! + ": " + bssid! break } } } return info } CS4500/5500 6 Ref. MOS4E, OS@Austin, Columbia, UWisc

  7. iOS/Android devices • 3 iPhones, 3 iPads • 2 Android phones, 2 Android tabs • Check out @Ali CS5530 7 Ref. CN5E, NT@UW, WUSTL

  8. Location Manager • Core Location Framework o var locationManager: CLLocationManager = CLLocationManager() • Location access permission o locationManager.requestWhenInUseAuthorization() o locationManager.requestAlwaysAuthorization() CS5530 8 Ref. CN5E, NT@UW, WUSTL

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend