Have you had one of your apps crash on your device and you want to know why? Well look at the crash log. Get it from your device with these instructions.
Category Archives: code
Update CCLabelTTF with int string
-(void) updateText WithInt: (int) val {
numValue += val;
NSString *numString = [NSString stringWithFormat:@"%i", numValue];
[textFieldName numString];
}
Cocos2d V2 HD graphics labelling convention
GameBGiPad1.png - For iPhone
GameBGiPad1-hd.png - For iPhone HD
GameBGiPad1-ipad.png - For iPad
GameBGiPad1-ipadhd.png - For iPad HD
Porting Photoshop Blend Modes To Cocos2D
Want a nice, easy to read and implement description of blend modes in Cocos2D? Well you won’t get it here on Tokeru, but you will on Nial Giacomelli’s site. Check it out. http://nial.me/2012/06/porting-photoshop-blendmodes-to-cocos2d/
Archiving
Real quick one, if you are trying to submit your app to iTunes through xcode and you find that the menu item Product->Build For->Build For Archiving is greyed out, then check your build target. It has to be IOS device, not one of the simulators.
Checking IOS version
Easy as, here it is for 6. You can change to 5’s if that’s what you need.
-(BOOL) isIOS6 {
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 6.0){
return YES;
}else{
return NO;
}
}
Xcode – Could not launch app – No such file or directory Error.
I’ve been expanding the amount of devices I have and returning to old code to try and sort out and update code that doesn’t run on newer IOS’s. While trying to compile Loopy Tunes, I came across the error  from Xcode, “could  not launch app, no such file or directory exists..” So here I found the solution due to one helpful blogger,
http://dhilipsiva.blogspot.com.au/2012/07/xcode-could-not-launch-app-no-such-file.html
Orientation always in Portrait iOS6
Right had to do a bit of research for this one, here is the fix I found that works from Natalie London
In your APP DELEGATE.m
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending){
[window setRootViewController:viewController]; // This is for IOS6.....
}else{
[window addSubview: viewController.view]; //This is for < IOS6....... (the old way)
}
In your ROOTVIEWCONTROLLER.m //will only be compiled for IOS6
FOR LANDSCAPE USE THIS
- (NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
- (BOOL) shouldAutorotate {
return YES;
}
FOR PORTRAIT USE THIS
- (NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortrait;
}
- (BOOL) shouldAutorotate {
return YES;
}
The page I got this from is
https://devforums.apple.com/message/734618#734618
Creating an Ad Hoc version of your app
I could write out how to do this, but I couldn’t do better than this post here.
http://www.musicalgeometry.com/?p=1237
And in case you need to know how to create your Ad Hoc Distribution Provisioning Profile, look at the Apple notes here
http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Conceptual/DevPortalGuide/CreatingandDownloadingaDistributionProvisioningProfile/CreatingandDownloadingaDistributionProvisioningProfile.html
And if you want to know how to add devices for testing. Get the UDID from the iphone or ipad, and in the the IOS Provisioning Portal go to “devices”. Select “add devices” in the top right corner. Enter the device name and device ID and hit “submit”.
EXC_BAD_ACCESS
Right so I get this one a lot, especially when I’m coding late at night and tired…which is most of the time. So, my main culprits are objects that I haven’t released in my dealloc method.
Especially look for anything that you created with ALLOC INIT, for example an array
[[NSMutableArray alloc] init]
You must, must, must release it.
Second most common is not removing the class from observing a Notification. So if you have something like
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(classMethod:) name:@"notificationName" object:nil];
Then again in your dealloc method, you must put this
[[NSNotificationCenter defaultCenter] removeObserver:self];
I’m sure there are more things, and I’ll add notes as I discover them.