I've just upgraded to XCode 4.5 GM and found out that you can now apply the '4" Retina' size to your view controller in the storyboard.
Now if I want to create an application that runs on both iPhone 4 and 5, of course I have to build every window twice, but I also have to detect whether the user has an iPhone with 3.5" or 4" screen and then apply the view.
How should I do that?
Relying in the size is wrong in so many levels. How about we ask to the system?
Taken from Best way to detect hardware type, iPhone4 or iPhone5?, edzio27 answer.
This way you can detect device family.
Really simple solution
This has been answered a hundred times but this solution worked the best for me. It's a simple helper function and doesn't require extending a system class.
Swift 3 Helper:
This is because it's easy to memorize a phone's inch sizes, like, "5.5 inch" or "4.7 inch" device but difficult to remember the exact pixel sizes.
This also gives you the opportunity to do something like this:
The "defaultValue" ensures that your code will always fallback to a safe size if Apple releases a new device size and you haven't updated your app yet.
Note that this is specific for phone apps, will need some changes for universal ones.