To have a UILabel print out a price float with 2 decimal places you'll want to cast a string with to except a float with 2 decimal places.
Entries Tagged 'iPhone Apps' ↓
iPhone How to: UItextField Value to Show Float with Zeros
August 31st, 2009 — XCode, iPhone Apps, iPhone Development
No Access to iPhone running OS 3.0.1 though XCode Organizer
August 29th, 2009 — XCode, iPhone Apps, iPhone Development
After updating the iPhone in iTunes to Software OS 3.0.1 I was unable to access it through the xcode organizer. After reinstalling the newest xocde (failed) and some digging I found a line of code you need to copy and paste into your terminal once, restart xcode, and you have access to pushing onto the iphone again.
Open up Terminal, copy below, paste and enter into terminal, restart xcode.
iPhone SDK CoreData Debugging Error 1560 & 1570
August 28th, 2009 — CoreData, Debugging, iPhone Apps, iPhone Development
One of my CoreData applications started acting buggy, and was spitting out a huge error dump on app close in the debug console. The errors spitting out didn't tell me anything but CoreData Error 1560 and 1570. Upon inspection I found on google that another layer of errors is stored in the CoreData foundation. On Stack OverFlow found a very useful function but re-wrote it because
was causing an error.
Add this into you applicationWillTerminate function in your Application Delegate
applicationWillTerminate: saves changes in the application's managed object context before the application terminates.
*/
- (void)applicationWillTerminate:(UIApplication *)application {
NSError* error;
if(![[self managedObjectContext] save:&error]) {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
if(detailedErrors != nil && [detailedErrors count] > 0) {
for(NSError* detailedError in detailedErrors) {
NSLog(@" DetailedError: %@", [detailedError userInfo]);
}
}
else {
NSLog(@" %@", [error userInfo]);
}
}
}
The original post can be found here
The cause of Error in my CoreData Application was an Attribute in my xcdatamodel file. An optional field was checked as indexed and not optional. The simple action of unchecking indexed and checking optional fixed a whole mass of errors.

How to Add a Home Navigation Button to the iPhone NavigationController
August 26th, 2009 — How to, UINavigationBar, iPhone Apps, iPhone Development
A quite useful button for a navigation controller with a deep stack would be a home button. It is simple to add.
In your RootViewController viewDidLoad Function
[super viewDidLoad];
UIBarButtonItem *homeButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Home", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(goHome:)] autorelease];
self.navigationItem.rightBarButtonItem = homeButton;
}
That will add a home button in to top right of your navigation controller
Create a function called go home in your rootViewController
- (void)goHome:(id) sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}
This function will pop your view controller to its root view
Why Develop iPhone Apps with PNGs
August 24th, 2009 — iPhone Apps, iPhone Development
PNG's kick ass, that being said, sometimes JPGs are smaller when compressed. Below is an except from Addison Wesley's iphone cook book.
"Xcode automatically optimizes your PNG images using the pngcrush utility shipped with the SDK. (You’ll find the program in the iPhoneOS platform folders in /Developer. Run it from the command line with the –iphoneswitch to convert standard PNG files to iPhone- formatted ones.) For this reason,use PNG images in your iPhone apps where possible as your preferred image format."
Now go batch resize your image catalogs into PNG format, now.