How to create a UITabBarController in code

Tab Bar Controllers are setup with an array of view controllers. We’ll create those first, then we simply give said array to our tab bar controller. In this example, this is a subclass of UITabBarController: – (void)viewDidLoad { [super viewDidLoad]; // let’s create several View Controllers with different colours each ViewController *vc1 = [self createViewcontrollerWithColor:[UIColor […]

How to swap out a store file in Core Data

You can switch out the NSPersistentStore file in your running Core Data app by first adding your new store file, then removing the previous one. Once done you must execute your fetch request again so that the new data is available. Hot-swapping stores assumes both NSPersistentStore files are based on the same model. It’s like […]

How to convert a file path into an NSURL (and back)

To convert a file path into an NSURL: NSURL *localURL = [NSURL fileURLWithPath:localPath]; To create a local path from an NSURL: NSString *localPath = [localURL filePathURL]; NSURLs can also be created directly from an NSString: NSURL *yourURL = [[NSURL alloc]initWithString:@”http://wpguru.co.uk”]; // or NSURL *yourURL = [NSURL URLWithString:@”http://wpguru.co.uk”]; If you’re ever tried to pass a local […]

How to find your own apps in Xcode

Sometimes it can be difficult to find which of your own apps are installed on a device, especially when you’ve made so many over the years and also have installed countless ones from the app store. Here’s how to list “your apps” in Xcode 5: connect the device head over to Window – Organizer – […]