Monday, December 13, 2010

NSDateFormatter:Convert NSDate to NSString description

Convert a NSDate to string in format "yyyy-MM-dd"

NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *dateString = [dateFormatter stringFromDate:[NSDate date]];
NSLog(dateString);

Saturday, December 11, 2010

iPhone Simulator (IndigoDevice) Internal Error

I got a strange "Internal Error" when building app with Xcode. Restarting Xcode and my Mac do not help. Finally, I found the solution from JPoz:
http://blog.jpoz.net/2009/05/24/iPhone-simulator-internal-error.html
"go into your (username)/Library/Application Support/ and delete the iPhone Simulator folder. Restart xcode and build your app."
It works fine and help a lot.

Thursday, November 25, 2010

Invisible UIActivityIndicatorView loading activity indicator on iPhone4

I found that a UIActivityIndicatorView is invisible on iphone4 while it's working fine on simulator or earlier iphone version. And it's because "UIActivityIndicatorViewStyleWhiteLarge" is invisible on white background on iphone4. After change style to "UIActivityIndicatorViewStyleGray", it shows up but no "large" option.

Tuesday, November 23, 2010

Push Notification:iPhone deviceToken convert to NSString

Here's how to convert the (NSData *)deviceToken to (NSString *):
NSString *deviceTokenString = [[deviceToken description] stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
// also remove the space
deviceTokenString = [deviceTokenString stringByReplacingOccurrencesOfString:@" " withString:@""];