Simple Way To Detect iOS6 vs iOS7 Note you can't use NSFoundationVersionNumber_iOS_7_0 if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { // Load resources for iOS 6.1 or earlier } else { // Load resources for iOS 7 or later }
Category: .General
Getting App Version Number
Get Build Version Number [[[NSBundle mainBundle] infoDictionary] objectForKey:@”CFBundleVersion”]]
Detect if device is iPad or iPhone
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { NSLog(@”This is an iPhone”); } else { NSLog(@”This is an iPad”); }
Triggering Device Functions
Open a webpage in safari [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”http://www.google.com”]]; Call a telephone number [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@”tel:0044-1234-567-890″]];
Creating Simple Code Files
To create a .m and .h file pair to use for shared functions etc Create Files Menu > File > New File > Mac OS X > C and C++ > C File Name it and ensure you change the extension from .c to .m Add to NewFile.h #import <UIKit/UIKit.h> Include Add import to the […]
Files
Project Files .xib MainWindow_iPhone.xib and MainWindow_iPad.xib contain the interface for your application. Double click to open in the interface builder. .plist ApName-Info.plist is the info property list which contains a list of the key-value pairs. These values specify things like the icon to display on the home screen, if the app needs a persistant WiFi […]
Change Application Name
Up To Date Guide http://xcodebook.com/2011/04/renaming-projects/ Change Complete Project Name Menu > Project > Edit Active Target > Build tab Select ‘All Configurations’ from Configuration. Scroll down to the ‘Packaging’ group > Product Name Double click it and enter the new name. Build and run and the name has changed. Change The Displayed Name Changing the […]
General Tips
Show Help For Something In Code Hold CTRL + ALT and double click the name in your code (windows keyboard – Option+Command for Mac keyboard) Switch Between .m And .h Files Hold CTRL + ALT and press UpArrow (windows keyboard – Option+Command for Mac keyboard)
Declarations
Declaring Variables Variables are declared inside { } Declaring Methods Methods are declared after }
.Overview
Project Files app delegate The starting point for the application – the app must have one. Manages a single top level UIWindow. application:didFinishLaunchingWithOptions Called right before the app is ready for the user – your chance to prepare the application for action before the user can do anything. xib doc window File's Owner An instance […]