iOS

Swift: Invoking Caller's Method with Protocols

One line problem/solution: using [Protocols](swift protocol optional) when delegating calls to the caller class from a Factory. I have a Button Factory (ButtonFactory.swift) which gives the user an instance of UIButton in a simple grid view (GridView.swift), which will invoke a method on the main class that calls the factory. A quick & simple solution to this would be like: - ButtonFactory.swift protocol ButtonDelegate { func buttonPressed(button:UIButton) } class ButtonFactory { var delegate:ButtonDelegate! func create(...) -> UIButton { let button = CustomButton() button.addTarget(self, action:…

Keep reading

iOS9: Sudden kCFStreamErrorDomainSSL Errors

Suddenly after upgrading my OS to El Capitan and downloading iOS 9 SDK for Xcode I began to experience the following errors when trying to reach Facebook Graph API: NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802) Error:Error Domain=NSURLErrorDomain Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made." ... _kCFNetworkCFStreamSSLErrorOriginalValue=-9802, _kCFStreamPropertySSLClientCertificateState=0, _kCFStreamErrorDomainKey=3, kCFStreamPropertySSLPeerCertificates=<CFArray 0x7c66c1f0 [0xf72098]>{type = immutable, count = 2, values = ( 0 : <cert(0x7ae10150) s: *.facebook.com i: DigiCert High Assurance CA-3> 1…

Keep reading

Simulating Network Status

To test application features that require a network connection such as Game Center, Store Kit or simple HTTP requests you need to be able to simulate various real-life conditions as well. You would want to see how your application behaves if the user doesn't have or has an unstable internet connection, or connection suddenly drops during an operation. Xcode iOS Simulator doesn't provide you such features by default but you can download Hardware IO Tools for Xcode simply by choosing: Xcode → Open Developer Tool → More Developer Tools And then login…

Keep reading