Enable SQL Debugging in Xcode4
If you would like to output the SQL being generated by Core Data, here is the quick steps:
- Go to Product -> Edit Scheme
- Choose Run YourAppName.app
- Add -com.apple.CoreData.SQLDebug 1 to the Arguments Passed On Launch panel
Eid Mubarak & Independence Day Malaysia
I wish Selamat Hari Raya to all my muslim readers and Happy Independence Day to all Malaysians.
Merdeka! Merdeka! Merdeka!
Limit the size of UITextField
// Text field delegates
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if ([[textField text] length] + [string length] - range.length > MAX_LENGTH) {
return NO;
} else {
return YES;
}
}
XML Date to CoreData NSDate
Here is code snippet to parse a XML string to Core Data NSDate.
NSString *string = [currentString stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSLocale* usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setLocale:usLocale]; [dateFormatter setDateFormat:@"EEE, dd MMM yyyy HH:mm:ss ZZ"]; NSDate *pubDate = [dateFormatter dateFromString:string];
