Thursday, 12 January 2012

Graphics Libraries

Drawing stuff directly in ios gets a bit slow as soon as you have more than a few images onscreen. So we should use a library like:

Cocos 2d tutorial
Cocos 2d with Box2d tutorial

For the more hard core there is Open GL

For full cross platform 3D goodness at a minimum $400 price tag (plus you'd need a copy of Maya) there is the rather awesome looking: Unity

Tuesday, 3 January 2012


How to replace the current controller with a new one. In this case GameController

GameController *c = [[GameController alloc] initWithNibName:@"GameController" bundle:nil];
[self presentModalViewController:c animated:YES];
[c release];

For a navigatable version with back functionality:

[self.navigationController pushViewController:c animated:YES];

Friday, 4 November 2011

App Store submission

Unlike the Android Market the Apple App Store submission is a pain in the backside. Here are my notes from repeatedly failing at it:

Setup your app details in Itunes Connect. Your bundle ID should look something like this: com.nuclearcarrot.oystererrors

Next manage your certificates and profiles at apple developer
Go to Provisioning. Create a Distribution Profile (Note a Developer Profile). Can not use a Wildcard AppId for this.

Your appid should look like this:

Download this baby and drag it into XCode.

Xcode Project -> Build Settings -> Code Signing and configure it as Iphone Distribution.

Monday, 18 July 2011

Check if Running on Simulator

How to add an if to check if you are running on the simulator:

   NSLog(@"APPIRATER NOTE: not supported on the iOS simulator.");
   // Do Live stuff


Sunday, 5 June 2011

Core Data schema change migration

Place the below in your:

- (NSPersistentStoreCoordinator *)persistentStoreCoordinator

To remove the old data store (clear out old data models):

[[NSFileManager defaultManager] removeItemAtURL:storeURL error:nil];

To migrate data using Lightweight Migration

[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES],NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

In Xcode 4 we migrate data models by:
select data model. (on left)
Apple - alt - 1 ( View - Utilities - File Inspector)
Versioned Data model (on right side of utilities window)

Wednesday, 11 May 2011

Camera + Action Sheets Basics

Header should implement:

@interface CapturedPhotoController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate> {

and then we paste these methods into the main file:

- (IBAction) takePictureButton: (id) sender {

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
NSLog(@"is camera ok");
UIActionSheet *photoSourceSheet = [[UIActionSheet alloc] initWithTitle:@"Select fugitive picture"
otherButtonTitles:@"Take new photo", @"Choose existing photo", nil, nil];

[photoSourceSheet showInView:self.view];
[photoSourceSheet release];
else {
NSLog(@"No camera");
UIImagePickerController* picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsEditing = YES;
[self presentModalViewController:picker animated:YES];

-(void) actionSheet:(UIActionSheet *) actionShet didDismissWithButtonIndex:(NSInteger)buttonIndex {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;

switch(buttonIndex) {
case 0:
NSLog(@"user wants to take new picture");
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.delegate = self;
picker.allowsEditing= YES;
case 1:
NSLog(@"user wants to choose existing picture");
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[picker release];
[self presentModalViewController:picker animated:YES];


-(void) imagePickerController:(UIImagePickerController *) picker
didFinishPickingImage:(UIImage*) image
editingInfo:(NSDictionary*) editingInfo {
self.fugitive.image = UIImagePNGRepresentation(image);
[self dismissModalViewControllerAnimated:YES];
[picker release];