$30 off During Our Annual Pro Sale. View Details »

My Way to Objective-C

高見龍
November 22, 2012

My Way to Objective-C

高見龍

November 22, 2012
Tweet

More Decks by 高見龍

Other Decks in Programming

Transcript

  1. # Ruby class Animal def say_something(words) puts words end end

    cat = Animal.new cat.say_something "hello, world"
  2. id

  3. - (id)init { self = [super init]; if (self) {

    // do some init things here } return self; }
  4. ^

  5. GCD

  6. # obj-c dispatch_queue_t queue = dispatch_queue_create("imageLoadingQueue", NULL); dispatch_async(queue, ^{ //

    start to load image here dispatch_async(dispatch_get_main_queue(), ^{ // image loaded, do something here }); });
  7. -(NSString *) getBookName { NSString *the_name = @"This is a

    book"; [the_name release]; return the_name; }
  8. -(NSString *) getBookName { NSString *the_name = @"This is a

    book"; return [the_name autorelease]; }
  9. // for-loop style NSArray* kids = ... for (int i

    = 0; i < kids.count; ++i) { NSString* kid = [kids objectAtIndex:i]; // do something }
  10. // block style NSArray* kids = ... [kids enumerateObjectsUsingBlock:^(NSString* kid,

    NSUInteger idx, BOOL *stop) { // do something here }];
  11. NSDictionary * kidsEnglishName = ... NSArray* keys = [dict allKeys];

    for (NSString* key in keys) { NSString* value = [dict objectForKey:key]; // do something else }
  12. 高見見龍龍 Conacts photo by Eddie Websie Blog Plurk Facebook Google

    Plus Twiter Email Mobile http://www.eddie.com.tw http://blog.eddie.com.tw http://www.plurk.com/aquarianboy http://www.facebook.com/eddiekao http://www.eddie.com.tw/+ https://twiter.com/#!/eddiekao [email protected] +886-928-617-687