R.I.P Steve Jobs

iOS Development,Journal,Mac OS X,Macbook 6 October 2011 0 Comments




You changed my life and my career. You changed the world for the better. Rest in Peace, Steve Jobs.

Enable SQL Debugging in Xcode4

iOS Development,Mac OS X,Objective-C 6 September 2011 0 Comments



If you would like to output the SQL being generated by Core Data, here is the quick steps:

  1. Go to Product -> Edit Scheme
  2. Choose Run YourAppName.app
  3. Add -com.apple.CoreData.SQLDebug 1 to the Arguments Passed On Launch panel

Eid Mubarak & Independence Day Malaysia

Off-Topic 31 August 2011 0 Comments



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

iOS Development,Mac OS X,Objective-C 27 August 2011 0 Comments

// 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;
  }
}

https://gist.github.com/1175468

XML Date to CoreData NSDate

iOS Development,Objective-C 26 June 2011 0 Comments

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];