├── README.md ├── SSASwiftReachability └── SSASwiftReachability.swift ├── SSASwiftReachabilityCover.png ├── SwiftReachability.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── SwiftReachability.xccheckout │ └── xcuserdata │ │ └── JorgeOvalle.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ ├── JorgeOvalle.xcuserdatad │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ │ ├── SwiftReachability.xcscheme │ │ └── xcschememanagement.plist │ └── SebastianSA.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ ├── SwiftReachability.xcscheme │ └── xcschememanagement.plist ├── SwiftReachability ├── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist └── ViewController.swift └── SwiftReachabilityTests ├── Info.plist └── SwiftReachabilityTests.swift /README.md: -------------------------------------------------------------------------------- 1 | ![SSASideMenu](https://github.com/SSA111/SSASwiftReachability/blob/master/SSASwiftReachabilityCover.png) 2 | 3 | [![](http://img.shields.io/badge/iOS-8.0%2B-blue.svg)]() [![](http://img.shields.io/badge/Swift-3.0-blue.svg)]() 4 | 5 | ###Usage 6 | 7 | ```swift 8 | override func viewDidLoad() { 9 | super.viewDidLoad() 10 | 11 | SSASwiftReachability.sharedManager?.startMonitoring() 12 | 13 | // MARK: Listen For Network Reachability Changes 14 | NotificationCenter.default.addObserver(self, selector: #selector(self.reachabilityStatusChanged(notification:)), name: NSNotification.Name(rawValue: SSAReachabilityDidChangeNotification), object: nil) 15 | } 16 | 17 | func reachabilityStatusChanged(notification: NSNotification) { 18 | if let info = notification.userInfo { 19 | if let s = info[SSAReachabilityNotificationStatusItem] { 20 | reachabilityStatusLabel.text = (s as AnyObject).description 21 | } 22 | } 23 | } 24 | ``` 25 | ###Installation 26 | As for now please clone the repository and drag the source folder into your project to use SSASwiftReachability. (Cocoapods & Carthage 27 | support coming soon) 28 | 29 | ###Author 30 | 31 | Sebastian Andersen 32 | 33 | Inspired by AFNetworkReachabilityManager 34 | 35 | ###License 36 | 37 | SSASwiftReachability is available under the MIT license. See the LICENSE file for more info. 38 | -------------------------------------------------------------------------------- /SSASwiftReachability/SSASwiftReachability.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SSASwiftReachability.swift 3 | // SSASwiftReachability 4 | // 5 | // Created by Sebastian Andersen on 05/02/15. 6 | // Copyright (c) 2015 SebastianAndersen. All rights reserved. 7 | // 8 | 9 | import SystemConfiguration 10 | import Foundation 11 | 12 | let SSAReachabilityDidChangeNotification = "ReachabilityChangedNotification" 13 | let SSAReachabilityNotificationStatusItem = "ReachabilityNotificationStatusItem" 14 | 15 | func callback(target: SCNetworkReachability, flags: SCNetworkReachabilityFlags, info: UnsafeMutableRawPointer?) { 16 | 17 | let reachability = Unmanaged.fromOpaque(UnsafeRawPointer(OpaquePointer(info))!).takeUnretainedValue() 18 | 19 | DispatchQueue.main.async { 20 | reachability.reachabilityCallback(flags) 21 | } 22 | } 23 | 24 | 25 | 26 | open class SSASwiftReachability { 27 | 28 | typealias ReachabilityStatusChangedClosure = (ReachabilityStatus) -> () 29 | 30 | // MARK: Public Enums 31 | 32 | enum ReachabilityStatus: Int { 33 | case unknown = -1 34 | case notReachable = 0 35 | case reachableViaWWAN = 1 36 | case reachableViaWiFi = 2 37 | case reachable = 3 38 | 39 | var description : String { 40 | get { 41 | switch(self) { 42 | case .unknown: 43 | return "Unknown" 44 | case .notReachable: 45 | return "Not Reachable" 46 | case .reachableViaWWAN: 47 | return "Reachable Via WWAN" 48 | case .reachableViaWiFi: 49 | return "Reachable Via WiFi" 50 | case .reachable: 51 | return "Reachable" 52 | } 53 | } 54 | } 55 | } 56 | 57 | enum ReachabilityAssociation: Int { 58 | case forAddress = 1 59 | case forAddressPair = 2 60 | case forName = 3 61 | } 62 | 63 | enum ReachabilityInformationMode: Int { 64 | case simple = 1 65 | case advanced = 2 66 | } 67 | 68 | // MARK: Public Variables 69 | 70 | var networkReachabilityStatus: ReachabilityStatus = .unknown 71 | var reachabilityAssociation: ReachabilityAssociation = .forName 72 | var reachabilityInformationMode: ReachabilityInformationMode = .simple 73 | 74 | var currentReachabilityString: String { 75 | return networkReachabilityStatus.description 76 | } 77 | 78 | // MARK: Public Optional Variables 79 | 80 | var reachabilityStatusChangedClosure: ReachabilityStatusChangedClosure? 81 | 82 | // MARK: Public Class Variables 83 | 84 | class var zeroAdress: sockaddr_in { 85 | var address: sockaddr_in = sockaddr_in(sin_len: __uint8_t(0), sin_family: sa_family_t(0), sin_port: in_port_t(0), sin_addr: in_addr(s_addr: 0), sin_zero: (0, 0, 0, 0, 0, 0, 0, 0)) 86 | address.sin_len = UInt8(MemoryLayout.size(ofValue: address)) 87 | address.sin_family = sa_family_t(AF_INET) 88 | 89 | return address 90 | } 91 | 92 | // MARK: Private Variables 93 | 94 | fileprivate var networkReachability: SCNetworkReachability? 95 | fileprivate var lastNetworkReachabilityStatus: ReachabilityStatus = .unknown 96 | 97 | // MARK: Singleton 98 | 99 | static let sharedManager: SSASwiftReachability? = SSASwiftReachability.managerForAddress(SSASwiftReachability.zeroAdress) 100 | 101 | // MARK: Initialization 102 | 103 | fileprivate init(reachabilityRef: SCNetworkReachability, reachabilityAssociation: ReachabilityAssociation) { 104 | self.networkReachability = reachabilityRef 105 | self.reachabilityAssociation = reachabilityAssociation 106 | } 107 | 108 | // MARK: Public Class Functions 109 | 110 | class func managerForDomain(_ domain: String) -> SSASwiftReachability? { 111 | let reachabilityRef: SCNetworkReachability? = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, (domain as NSString).utf8String!) 112 | return SSASwiftReachability(reachabilityRef: reachabilityRef!, reachabilityAssociation: .forName) 113 | } 114 | 115 | class func managerForAddress(_ address: sockaddr_in) -> SSASwiftReachability? { 116 | var addressVar = address 117 | let reachabilityRef = withUnsafePointer(to: &addressVar) { 118 | $0.withMemoryRebound(to: sockaddr.self, capacity: 1) {zeroSockAddress in 119 | SCNetworkReachabilityCreateWithAddress(nil, zeroSockAddress) 120 | } 121 | } 122 | return SSASwiftReachability(reachabilityRef: reachabilityRef! as SCNetworkReachability, reachabilityAssociation: .forAddress) 123 | } 124 | 125 | // MARK: Public Functions 126 | 127 | func isReachable() -> Bool { 128 | return networkReachabilityStatus == .reachable || networkReachabilityStatus == .reachableViaWWAN || networkReachabilityStatus == .reachableViaWiFi 129 | } 130 | 131 | func isReachableViaWWAN() -> Bool { 132 | return networkReachabilityStatus == .reachableViaWWAN 133 | } 134 | 135 | func isReachableViaWiFi() -> Bool { 136 | return networkReachabilityStatus == .reachableViaWiFi 137 | } 138 | 139 | // MARK: Start Monitoring For Reachability Changes 140 | 141 | func startMonitoring() { 142 | stopMonitoring() 143 | guard let reachability = networkReachability else { return } 144 | 145 | let statusClosure: ReachabilityStatusChangedClosure = { [weak self] status in 146 | self?.networkReachabilityStatus = status 147 | } 148 | 149 | var context = SCNetworkReachabilityContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil) 150 | context.info = Unmanaged.passUnretained(self).toOpaque() 151 | 152 | 153 | SCNetworkReachabilitySetCallback(reachability, callback, &context) 154 | SCNetworkReachabilityScheduleWithRunLoop(reachability, CFRunLoopGetMain(), CFRunLoopMode.commonModes.rawValue) 155 | 156 | 157 | 158 | 159 | // Get Initial Reachability Status 160 | DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background).async { 161 | var flags: SCNetworkReachabilityFlags = SCNetworkReachabilityFlags() 162 | SCNetworkReachabilityGetFlags(reachability, &flags) 163 | let status: ReachabilityStatus = self.reachabilityStatus(flags) 164 | 165 | DispatchQueue.main.async { 166 | statusClosure(status) 167 | NotificationCenter.default.post(name: Notification.Name(rawValue: SSAReachabilityDidChangeNotification), object:self, userInfo: [SSAReachabilityNotificationStatusItem : "\(status)"]) 168 | } 169 | } 170 | } 171 | 172 | // MARK: Stop Monitoring For Reachability Changes 173 | 174 | func stopMonitoring() { 175 | guard let reachability = networkReachability else { return } 176 | SCNetworkReachabilityUnscheduleFromRunLoop(reachability, CFRunLoopGetMain(), CFRunLoopMode.commonModes.rawValue); 177 | } 178 | 179 | // MARK: Handle Reachability Change 180 | 181 | func reachabilityCallback(_ flags: SCNetworkReachabilityFlags) { 182 | let status: ReachabilityStatus = reachabilityStatus(flags) 183 | guard status != self.networkReachabilityStatus else { return } 184 | 185 | if let closure = reachabilityStatusChangedClosure { 186 | closure(status) 187 | } 188 | DispatchQueue.main.async { 189 | self.lastNetworkReachabilityStatus = self.networkReachabilityStatus 190 | self.networkReachabilityStatus = status 191 | NotificationCenter.default.post(name: Notification.Name(rawValue: SSAReachabilityDidChangeNotification), object:self, userInfo: [SSAReachabilityNotificationStatusItem : "\(status)"]) 192 | } 193 | } 194 | 195 | // MARK: Private Functions 196 | 197 | fileprivate func reachabilityStatus(_ flags: SCNetworkReachabilityFlags) -> ReachabilityStatus { 198 | let isReachable: Bool = flags.contains(.reachable) 199 | let isConnectionRequired: Bool = flags.contains(.connectionRequired) 200 | let canConnectAutomatically: Bool = flags.contains(.connectionOnDemand) || flags.contains( .connectionOnTraffic) 201 | let canConnectWithoutUserInteraction = canConnectAutomatically && !flags.contains(.interventionRequired) 202 | let isNetworkReachable: Bool = (isReachable && (!isConnectionRequired || canConnectWithoutUserInteraction)) 203 | #if os(iOS) 204 | let isOnWWAN: Bool = flags.contains(SCNetworkReachabilityFlags.isWWAN) 205 | #endif 206 | var status: ReachabilityStatus = .unknown 207 | 208 | if !isNetworkReachable { 209 | status = .notReachable 210 | } else { 211 | switch reachabilityInformationMode { 212 | case .simple: 213 | status = .reachable 214 | case .advanced: 215 | #if os(iOS) 216 | if isOnWWAN { 217 | #if (arch(i386) || arch(x86_64)) && os(iOS) 218 | status = .reachableViaWWAN 219 | #endif 220 | } else { 221 | status = .reachableViaWiFi 222 | } 223 | #else 224 | status = .ReachableViaWiFi 225 | #endif 226 | } 227 | } 228 | 229 | return status 230 | } 231 | 232 | // MARK: Deinitialization 233 | 234 | deinit { 235 | stopMonitoring() 236 | networkReachability = nil 237 | } 238 | 239 | } 240 | -------------------------------------------------------------------------------- /SSASwiftReachabilityCover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SSA111/SSASwiftReachability/308ff52a4f75671818d6fa0156d1b053bf1ac59b/SSASwiftReachabilityCover.png -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DC1791181BA325B40063B5CB /* SSASwiftReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1791171BA325B40063B5CB /* SSASwiftReachability.swift */; }; 11 | DC85FA1D1A83DC2A0044B8A3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC85FA1C1A83DC2A0044B8A3 /* AppDelegate.swift */; }; 12 | DC85FA1F1A83DC2A0044B8A3 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC85FA1E1A83DC2A0044B8A3 /* ViewController.swift */; }; 13 | DC85FA221A83DC2A0044B8A3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DC85FA201A83DC2A0044B8A3 /* Main.storyboard */; }; 14 | DC85FA241A83DC2A0044B8A3 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DC85FA231A83DC2A0044B8A3 /* Images.xcassets */; }; 15 | DC85FA271A83DC2A0044B8A3 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = DC85FA251A83DC2A0044B8A3 /* LaunchScreen.xib */; }; 16 | DC85FA331A83DC2B0044B8A3 /* SwiftReachabilityTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC85FA321A83DC2B0044B8A3 /* SwiftReachabilityTests.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | DC85FA2D1A83DC2A0044B8A3 /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = DC85FA0F1A83DC290044B8A3 /* Project object */; 23 | proxyType = 1; 24 | remoteGlobalIDString = DC85FA161A83DC2A0044B8A3; 25 | remoteInfo = SwiftReachability; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | DC1791171BA325B40063B5CB /* SSASwiftReachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSASwiftReachability.swift; path = SSASwiftReachability/SSASwiftReachability.swift; sourceTree = SOURCE_ROOT; }; 31 | DC85FA171A83DC2A0044B8A3 /* SwiftReachability.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftReachability.app; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | DC85FA1B1A83DC2A0044B8A3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | DC85FA1C1A83DC2A0044B8A3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 34 | DC85FA1E1A83DC2A0044B8A3 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 35 | DC85FA211A83DC2A0044B8A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 36 | DC85FA231A83DC2A0044B8A3 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 37 | DC85FA261A83DC2A0044B8A3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 38 | DC85FA2C1A83DC2A0044B8A3 /* SwiftReachabilityTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftReachabilityTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39 | DC85FA311A83DC2B0044B8A3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 40 | DC85FA321A83DC2B0044B8A3 /* SwiftReachabilityTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftReachabilityTests.swift; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | DC85FA141A83DC2A0044B8A3 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 0; 50 | }; 51 | DC85FA291A83DC2A0044B8A3 /* Frameworks */ = { 52 | isa = PBXFrameworksBuildPhase; 53 | buildActionMask = 2147483647; 54 | files = ( 55 | ); 56 | runOnlyForDeploymentPostprocessing = 0; 57 | }; 58 | /* End PBXFrameworksBuildPhase section */ 59 | 60 | /* Begin PBXGroup section */ 61 | DC85FA0E1A83DC290044B8A3 = { 62 | isa = PBXGroup; 63 | children = ( 64 | DC85FA191A83DC2A0044B8A3 /* SwiftReachability */, 65 | DC85FA2F1A83DC2B0044B8A3 /* SwiftReachabilityTests */, 66 | DC85FA181A83DC2A0044B8A3 /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | DC85FA181A83DC2A0044B8A3 /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | DC85FA171A83DC2A0044B8A3 /* SwiftReachability.app */, 74 | DC85FA2C1A83DC2A0044B8A3 /* SwiftReachabilityTests.xctest */, 75 | ); 76 | name = Products; 77 | sourceTree = ""; 78 | }; 79 | DC85FA191A83DC2A0044B8A3 /* SwiftReachability */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | DCAC83131BA316DD008110B4 /* SSASwiftReachability */, 83 | DC85FA1C1A83DC2A0044B8A3 /* AppDelegate.swift */, 84 | DC85FA1E1A83DC2A0044B8A3 /* ViewController.swift */, 85 | DC85FA201A83DC2A0044B8A3 /* Main.storyboard */, 86 | DC85FA231A83DC2A0044B8A3 /* Images.xcassets */, 87 | DC85FA251A83DC2A0044B8A3 /* LaunchScreen.xib */, 88 | DC85FA1A1A83DC2A0044B8A3 /* Supporting Files */, 89 | ); 90 | path = SwiftReachability; 91 | sourceTree = ""; 92 | }; 93 | DC85FA1A1A83DC2A0044B8A3 /* Supporting Files */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | DC85FA1B1A83DC2A0044B8A3 /* Info.plist */, 97 | ); 98 | name = "Supporting Files"; 99 | sourceTree = ""; 100 | }; 101 | DC85FA2F1A83DC2B0044B8A3 /* SwiftReachabilityTests */ = { 102 | isa = PBXGroup; 103 | children = ( 104 | DC85FA321A83DC2B0044B8A3 /* SwiftReachabilityTests.swift */, 105 | DC85FA301A83DC2B0044B8A3 /* Supporting Files */, 106 | ); 107 | path = SwiftReachabilityTests; 108 | sourceTree = ""; 109 | }; 110 | DC85FA301A83DC2B0044B8A3 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | DC85FA311A83DC2B0044B8A3 /* Info.plist */, 114 | ); 115 | name = "Supporting Files"; 116 | sourceTree = ""; 117 | }; 118 | DCAC83131BA316DD008110B4 /* SSASwiftReachability */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | DC1791171BA325B40063B5CB /* SSASwiftReachability.swift */, 122 | ); 123 | name = SSASwiftReachability; 124 | sourceTree = ""; 125 | }; 126 | /* End PBXGroup section */ 127 | 128 | /* Begin PBXNativeTarget section */ 129 | DC85FA161A83DC2A0044B8A3 /* SwiftReachability */ = { 130 | isa = PBXNativeTarget; 131 | buildConfigurationList = DC85FA361A83DC2B0044B8A3 /* Build configuration list for PBXNativeTarget "SwiftReachability" */; 132 | buildPhases = ( 133 | DC85FA131A83DC2A0044B8A3 /* Sources */, 134 | DC85FA141A83DC2A0044B8A3 /* Frameworks */, 135 | DC85FA151A83DC2A0044B8A3 /* Resources */, 136 | ); 137 | buildRules = ( 138 | ); 139 | dependencies = ( 140 | ); 141 | name = SwiftReachability; 142 | productName = SwiftReachability; 143 | productReference = DC85FA171A83DC2A0044B8A3 /* SwiftReachability.app */; 144 | productType = "com.apple.product-type.application"; 145 | }; 146 | DC85FA2B1A83DC2A0044B8A3 /* SwiftReachabilityTests */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = DC85FA391A83DC2B0044B8A3 /* Build configuration list for PBXNativeTarget "SwiftReachabilityTests" */; 149 | buildPhases = ( 150 | DC85FA281A83DC2A0044B8A3 /* Sources */, 151 | DC85FA291A83DC2A0044B8A3 /* Frameworks */, 152 | DC85FA2A1A83DC2A0044B8A3 /* Resources */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | DC85FA2E1A83DC2A0044B8A3 /* PBXTargetDependency */, 158 | ); 159 | name = SwiftReachabilityTests; 160 | productName = SwiftReachabilityTests; 161 | productReference = DC85FA2C1A83DC2A0044B8A3 /* SwiftReachabilityTests.xctest */; 162 | productType = "com.apple.product-type.bundle.unit-test"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | DC85FA0F1A83DC290044B8A3 /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastSwiftMigration = 0700; 171 | LastSwiftUpdateCheck = 0700; 172 | LastUpgradeCheck = 0800; 173 | ORGANIZATIONNAME = SebastianAndersen; 174 | TargetAttributes = { 175 | DC85FA161A83DC2A0044B8A3 = { 176 | CreatedOnToolsVersion = 6.1.1; 177 | }; 178 | DC85FA2B1A83DC2A0044B8A3 = { 179 | CreatedOnToolsVersion = 6.1.1; 180 | TestTargetID = DC85FA161A83DC2A0044B8A3; 181 | }; 182 | }; 183 | }; 184 | buildConfigurationList = DC85FA121A83DC2A0044B8A3 /* Build configuration list for PBXProject "SwiftReachability" */; 185 | compatibilityVersion = "Xcode 3.2"; 186 | developmentRegion = English; 187 | hasScannedForEncodings = 0; 188 | knownRegions = ( 189 | en, 190 | Base, 191 | ); 192 | mainGroup = DC85FA0E1A83DC290044B8A3; 193 | productRefGroup = DC85FA181A83DC2A0044B8A3 /* Products */; 194 | projectDirPath = ""; 195 | projectRoot = ""; 196 | targets = ( 197 | DC85FA161A83DC2A0044B8A3 /* SwiftReachability */, 198 | DC85FA2B1A83DC2A0044B8A3 /* SwiftReachabilityTests */, 199 | ); 200 | }; 201 | /* End PBXProject section */ 202 | 203 | /* Begin PBXResourcesBuildPhase section */ 204 | DC85FA151A83DC2A0044B8A3 /* Resources */ = { 205 | isa = PBXResourcesBuildPhase; 206 | buildActionMask = 2147483647; 207 | files = ( 208 | DC85FA221A83DC2A0044B8A3 /* Main.storyboard in Resources */, 209 | DC85FA271A83DC2A0044B8A3 /* LaunchScreen.xib in Resources */, 210 | DC85FA241A83DC2A0044B8A3 /* Images.xcassets in Resources */, 211 | ); 212 | runOnlyForDeploymentPostprocessing = 0; 213 | }; 214 | DC85FA2A1A83DC2A0044B8A3 /* Resources */ = { 215 | isa = PBXResourcesBuildPhase; 216 | buildActionMask = 2147483647; 217 | files = ( 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXResourcesBuildPhase section */ 222 | 223 | /* Begin PBXSourcesBuildPhase section */ 224 | DC85FA131A83DC2A0044B8A3 /* Sources */ = { 225 | isa = PBXSourcesBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | DC85FA1F1A83DC2A0044B8A3 /* ViewController.swift in Sources */, 229 | DC1791181BA325B40063B5CB /* SSASwiftReachability.swift in Sources */, 230 | DC85FA1D1A83DC2A0044B8A3 /* AppDelegate.swift in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | DC85FA281A83DC2A0044B8A3 /* Sources */ = { 235 | isa = PBXSourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | DC85FA331A83DC2B0044B8A3 /* SwiftReachabilityTests.swift in Sources */, 239 | ); 240 | runOnlyForDeploymentPostprocessing = 0; 241 | }; 242 | /* End PBXSourcesBuildPhase section */ 243 | 244 | /* Begin PBXTargetDependency section */ 245 | DC85FA2E1A83DC2A0044B8A3 /* PBXTargetDependency */ = { 246 | isa = PBXTargetDependency; 247 | target = DC85FA161A83DC2A0044B8A3 /* SwiftReachability */; 248 | targetProxy = DC85FA2D1A83DC2A0044B8A3 /* PBXContainerItemProxy */; 249 | }; 250 | /* End PBXTargetDependency section */ 251 | 252 | /* Begin PBXVariantGroup section */ 253 | DC85FA201A83DC2A0044B8A3 /* Main.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | DC85FA211A83DC2A0044B8A3 /* Base */, 257 | ); 258 | name = Main.storyboard; 259 | sourceTree = ""; 260 | }; 261 | DC85FA251A83DC2A0044B8A3 /* LaunchScreen.xib */ = { 262 | isa = PBXVariantGroup; 263 | children = ( 264 | DC85FA261A83DC2A0044B8A3 /* Base */, 265 | ); 266 | name = LaunchScreen.xib; 267 | sourceTree = ""; 268 | }; 269 | /* End PBXVariantGroup section */ 270 | 271 | /* Begin XCBuildConfiguration section */ 272 | DC85FA341A83DC2B0044B8A3 /* Debug */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 277 | CLANG_CXX_LIBRARY = "libc++"; 278 | CLANG_ENABLE_MODULES = YES; 279 | CLANG_ENABLE_OBJC_ARC = YES; 280 | CLANG_WARN_BOOL_CONVERSION = YES; 281 | CLANG_WARN_CONSTANT_CONVERSION = YES; 282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 283 | CLANG_WARN_EMPTY_BODY = YES; 284 | CLANG_WARN_ENUM_CONVERSION = YES; 285 | CLANG_WARN_INFINITE_RECURSION = YES; 286 | CLANG_WARN_INT_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 289 | CLANG_WARN_UNREACHABLE_CODE = YES; 290 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 291 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 292 | COPY_PHASE_STRIP = NO; 293 | ENABLE_STRICT_OBJC_MSGSEND = YES; 294 | ENABLE_TESTABILITY = YES; 295 | GCC_C_LANGUAGE_STANDARD = gnu99; 296 | GCC_DYNAMIC_NO_PIC = NO; 297 | GCC_NO_COMMON_BLOCKS = YES; 298 | GCC_OPTIMIZATION_LEVEL = 0; 299 | GCC_PREPROCESSOR_DEFINITIONS = ( 300 | "DEBUG=1", 301 | "$(inherited)", 302 | ); 303 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 304 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 305 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 306 | GCC_WARN_UNDECLARED_SELECTOR = YES; 307 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 308 | GCC_WARN_UNUSED_FUNCTION = YES; 309 | GCC_WARN_UNUSED_VARIABLE = YES; 310 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 311 | MTL_ENABLE_DEBUG_INFO = YES; 312 | ONLY_ACTIVE_ARCH = YES; 313 | SDKROOT = iphoneos; 314 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 315 | SWIFT_VERSION = 3.0; 316 | }; 317 | name = Debug; 318 | }; 319 | DC85FA351A83DC2B0044B8A3 /* Release */ = { 320 | isa = XCBuildConfiguration; 321 | buildSettings = { 322 | ALWAYS_SEARCH_USER_PATHS = NO; 323 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 324 | CLANG_CXX_LIBRARY = "libc++"; 325 | CLANG_ENABLE_MODULES = YES; 326 | CLANG_ENABLE_OBJC_ARC = YES; 327 | CLANG_WARN_BOOL_CONVERSION = YES; 328 | CLANG_WARN_CONSTANT_CONVERSION = YES; 329 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 330 | CLANG_WARN_EMPTY_BODY = YES; 331 | CLANG_WARN_ENUM_CONVERSION = YES; 332 | CLANG_WARN_INFINITE_RECURSION = YES; 333 | CLANG_WARN_INT_CONVERSION = YES; 334 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 335 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 336 | CLANG_WARN_UNREACHABLE_CODE = YES; 337 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 338 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 339 | COPY_PHASE_STRIP = YES; 340 | ENABLE_NS_ASSERTIONS = NO; 341 | ENABLE_STRICT_OBJC_MSGSEND = YES; 342 | GCC_C_LANGUAGE_STANDARD = gnu99; 343 | GCC_NO_COMMON_BLOCKS = YES; 344 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 345 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 346 | GCC_WARN_UNDECLARED_SELECTOR = YES; 347 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 348 | GCC_WARN_UNUSED_FUNCTION = YES; 349 | GCC_WARN_UNUSED_VARIABLE = YES; 350 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 351 | MTL_ENABLE_DEBUG_INFO = NO; 352 | SDKROOT = iphoneos; 353 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 354 | SWIFT_VERSION = 3.0; 355 | VALIDATE_PRODUCT = YES; 356 | }; 357 | name = Release; 358 | }; 359 | DC85FA371A83DC2B0044B8A3 /* Debug */ = { 360 | isa = XCBuildConfiguration; 361 | buildSettings = { 362 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 363 | CLANG_ENABLE_MODULES = YES; 364 | INFOPLIST_FILE = SwiftReachability/Info.plist; 365 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 366 | PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; 367 | PRODUCT_NAME = "$(TARGET_NAME)"; 368 | SWIFT_OBJC_BRIDGING_HEADER = ""; 369 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 370 | SWIFT_VERSION = 3.0; 371 | }; 372 | name = Debug; 373 | }; 374 | DC85FA381A83DC2B0044B8A3 /* Release */ = { 375 | isa = XCBuildConfiguration; 376 | buildSettings = { 377 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 378 | CLANG_ENABLE_MODULES = YES; 379 | INFOPLIST_FILE = SwiftReachability/Info.plist; 380 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 381 | PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; 382 | PRODUCT_NAME = "$(TARGET_NAME)"; 383 | SWIFT_OBJC_BRIDGING_HEADER = ""; 384 | SWIFT_VERSION = 3.0; 385 | }; 386 | name = Release; 387 | }; 388 | DC85FA3A1A83DC2B0044B8A3 /* Debug */ = { 389 | isa = XCBuildConfiguration; 390 | buildSettings = { 391 | BUNDLE_LOADER = "$(TEST_HOST)"; 392 | FRAMEWORK_SEARCH_PATHS = ( 393 | "$(SDKROOT)/Developer/Library/Frameworks", 394 | "$(inherited)", 395 | ); 396 | GCC_PREPROCESSOR_DEFINITIONS = ( 397 | "DEBUG=1", 398 | "$(inherited)", 399 | ); 400 | INFOPLIST_FILE = SwiftReachabilityTests/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 402 | PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; 403 | PRODUCT_NAME = "$(TARGET_NAME)"; 404 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftReachability.app/SwiftReachability"; 405 | }; 406 | name = Debug; 407 | }; 408 | DC85FA3B1A83DC2B0044B8A3 /* Release */ = { 409 | isa = XCBuildConfiguration; 410 | buildSettings = { 411 | BUNDLE_LOADER = "$(TEST_HOST)"; 412 | FRAMEWORK_SEARCH_PATHS = ( 413 | "$(SDKROOT)/Developer/Library/Frameworks", 414 | "$(inherited)", 415 | ); 416 | INFOPLIST_FILE = SwiftReachabilityTests/Info.plist; 417 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 418 | PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; 419 | PRODUCT_NAME = "$(TARGET_NAME)"; 420 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftReachability.app/SwiftReachability"; 421 | }; 422 | name = Release; 423 | }; 424 | /* End XCBuildConfiguration section */ 425 | 426 | /* Begin XCConfigurationList section */ 427 | DC85FA121A83DC2A0044B8A3 /* Build configuration list for PBXProject "SwiftReachability" */ = { 428 | isa = XCConfigurationList; 429 | buildConfigurations = ( 430 | DC85FA341A83DC2B0044B8A3 /* Debug */, 431 | DC85FA351A83DC2B0044B8A3 /* Release */, 432 | ); 433 | defaultConfigurationIsVisible = 0; 434 | defaultConfigurationName = Release; 435 | }; 436 | DC85FA361A83DC2B0044B8A3 /* Build configuration list for PBXNativeTarget "SwiftReachability" */ = { 437 | isa = XCConfigurationList; 438 | buildConfigurations = ( 439 | DC85FA371A83DC2B0044B8A3 /* Debug */, 440 | DC85FA381A83DC2B0044B8A3 /* Release */, 441 | ); 442 | defaultConfigurationIsVisible = 0; 443 | defaultConfigurationName = Release; 444 | }; 445 | DC85FA391A83DC2B0044B8A3 /* Build configuration list for PBXNativeTarget "SwiftReachabilityTests" */ = { 446 | isa = XCConfigurationList; 447 | buildConfigurations = ( 448 | DC85FA3A1A83DC2B0044B8A3 /* Debug */, 449 | DC85FA3B1A83DC2B0044B8A3 /* Release */, 450 | ); 451 | defaultConfigurationIsVisible = 0; 452 | defaultConfigurationName = Release; 453 | }; 454 | /* End XCConfigurationList section */ 455 | }; 456 | rootObject = DC85FA0F1A83DC290044B8A3 /* Project object */; 457 | } 458 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/project.xcworkspace/xcshareddata/SwiftReachability.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | C49F52A9-1C0D-4918-B165-2B35E1782275 9 | IDESourceControlProjectName 10 | project 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 63D783A975688D2A9771174BF5A2765E4CE403D3 14 | https://github.com/SSA111/SSASwiftReachability.git 15 | 16 | IDESourceControlProjectPath 17 | SwiftReachability.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 63D783A975688D2A9771174BF5A2765E4CE403D3 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/SSA111/SSASwiftReachability.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 63D783A975688D2A9771174BF5A2765E4CE403D3 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 63D783A975688D2A9771174BF5A2765E4CE403D3 36 | IDESourceControlWCCName 37 | SwiftReachability 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/project.xcworkspace/xcuserdata/JorgeOvalle.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SSA111/SSASwiftReachability/308ff52a4f75671818d6fa0156d1b053bf1ac59b/SwiftReachability.xcodeproj/project.xcworkspace/xcuserdata/JorgeOvalle.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/xcuserdata/JorgeOvalle.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/xcuserdata/JorgeOvalle.xcuserdatad/xcschemes/SwiftReachability.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 66 | 72 | 73 | 74 | 75 | 76 | 77 | 83 | 85 | 91 | 92 | 93 | 94 | 96 | 97 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/xcuserdata/JorgeOvalle.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SwiftReachability.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DC85FA161A83DC2A0044B8A3 16 | 17 | primary 18 | 19 | 20 | DC85FA2B1A83DC2A0044B8A3 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/xcuserdata/SebastianSA.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/xcuserdata/SebastianSA.xcuserdatad/xcschemes/SwiftReachability.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 67 | 68 | 78 | 80 | 86 | 87 | 88 | 89 | 90 | 91 | 97 | 99 | 105 | 106 | 107 | 108 | 110 | 111 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /SwiftReachability.xcodeproj/xcuserdata/SebastianSA.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | SwiftReachability.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DC85FA161A83DC2A0044B8A3 16 | 17 | primary 18 | 19 | 20 | DC85FA2B1A83DC2A0044B8A3 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /SwiftReachability/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SSASwiftReachability 4 | // 5 | // Created by Sebastian Andersen on 05/02/15. 6 | // Copyright (c) 2015 SebastianAndersen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | // Override point for customization after application launch. 19 | 20 | SSASwiftReachability.sharedManager?.startMonitoring() 21 | 22 | return true 23 | } 24 | 25 | func applicationWillResignActive(_ application: UIApplication) { 26 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 27 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 28 | } 29 | 30 | func applicationDidEnterBackground(_ application: UIApplication) { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | func applicationWillEnterForeground(_ application: UIApplication) { 36 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 37 | } 38 | 39 | func applicationDidBecomeActive(_ application: UIApplication) { 40 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 41 | } 42 | 43 | func applicationWillTerminate(_ application: UIApplication) { 44 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 45 | } 46 | 47 | 48 | } 49 | 50 | -------------------------------------------------------------------------------- /SwiftReachability/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /SwiftReachability/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /SwiftReachability/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /SwiftReachability/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /SwiftReachability/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SSASwiftReachability 4 | // 5 | // Created by Sebastian Andersen on 05/02/15. 6 | // Copyright (c) 2015 SebastianAndersen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewController: UIViewController { 12 | 13 | // MARK: Storyboard Variables 14 | @IBOutlet weak var reachabilityStatusLabel: UILabel! 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | 19 | SSASwiftReachability.sharedManager?.startMonitoring() 20 | 21 | // MARK: Listen For Network Reachability Changes 22 | NotificationCenter.default.addObserver(self, selector: #selector(self.reachabilityStatusChanged(notification:)), name: NSNotification.Name(rawValue: SSAReachabilityDidChangeNotification), object: nil) 23 | } 24 | 25 | func reachabilityStatusChanged(notification: NSNotification) { 26 | if let info = notification.userInfo { 27 | if let s = info[SSAReachabilityNotificationStatusItem] { 28 | reachabilityStatusLabel.text = (s as AnyObject).description 29 | } 30 | } 31 | } 32 | 33 | override func didReceiveMemoryWarning() { 34 | super.didReceiveMemoryWarning() 35 | } 36 | } 37 | 38 | -------------------------------------------------------------------------------- /SwiftReachabilityTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /SwiftReachabilityTests/SwiftReachabilityTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftReachabilityTests.swift 3 | // SwiftReachabilityTests 4 | // 5 | // Created by Sebastian S. Andersen on 05/02/15. 6 | // Copyright (c) 2015 SebastianAndersen. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SwiftReachabilityTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measureBlock() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------