NSURLSession/NSURLConnection HTTP load failed on iOS 9

Apple’s Technote on App Transport Security is very handy; it helped us find a more secure solution to our issue. Hopefully this will help someone else. We were having issues connecting to Amazon S3 URLs that appeared to be perfectly valid, TLSv12 HTTPS URLs. Turns out we had to disable NSExceptionRequiresForwardSecrecy to enable another handful … Read more

UICollectionView Self Sizing Cells with Auto Layout

This answer is outdated from iOS 14 with the addition of compositional layouts. Please consider updating the new API Updated for Swift 5 preferredLayoutAttributesFittingAttributes renamed to preferredLayoutAttributesFitting and use auto sizing Updated for Swift 4 systemLayoutSizeFittingSize renamed to systemLayoutSizeFitting Updated for iOS 9 After seeing my GitHub solution break under iOS 9 I finally got … Read more

SpriteKit – Creating a timer

In Sprite Kit do not use NSTimer, performSelector:afterDelay: or Grand Central Dispatch (GCD, ie any dispatch_… method) because these timing methods ignore a node’s, scene’s or the view’s paused state. Moreover you do not know at which point in the game loop they are executed which can cause a variety of issues depending on what … Read more

NSNotificationCenter addObserver in Swift

Swift 4.0 & Xcode 9.0+: Send(Post) Notification: NotificationCenter.default.post(name: Notification.Name(“NotificationIdentifier”), object: nil) OR NotificationCenter.default.post(name: Notification.Name(“NotificationIdentifier”), object: nil, userInfo: [“Renish”:”Dadhaniya”]) Receive(Get) Notification: NotificationCenter.default.addObserver(self, selector: #selector(self.methodOfReceivedNotification(notification:)), name: Notification.Name(“NotificationIdentifier”), object: nil) Function-Method handler for received Notification: @objc func methodOfReceivedNotification(notification: Notification) {} Swift 3.0 & Xcode 8.0+: Send(Post) Notification: NotificationCenter.default.post(name: Notification.Name(“NotificationIdentifier”), object: nil) Receive(Get) Notification: NotificationCenter.default.addObserver(self, selector: #selector(YourClassName.methodOfReceivedNotification(notification:)), name: Notification.Name(“NotificationIdentifier”), … Read more

How to get device make and model on iOS?

EITHER try this library: http://github.com/erica/uidevice-extension/ (by Erica Sadun). (The library is 7-8 years old, and hence is obsolete) (Sample Code): [[UIDevice currentDevice] platformType] // ex: UIDevice4GiPhone [[UIDevice currentDevice] platformString] // ex: @”iPhone 4G” OR You can use this method: You can get the device model number using uname from sys/utsname.h. For example: Objective-C #import <sys/utsname.h> … Read more