My Way to Objective-C

F2dcf6633971844e19ca96ea294ba976?s=47 高見龍
November 22, 2012

My Way to Objective-C

F2dcf6633971844e19ca96ea294ba976?s=128

高見龍

November 22, 2012
Tweet

Transcript

  1. 2.
  2. 8.
  3. 10.
  4. 14.
  5. 18.

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

    cat = Animal.new cat.say_something "hello, world"
  6. 23.
  7. 27.
  8. 29.
  9. 34.

    id

  10. 37.

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

    // do some init things here } return self; }
  11. 38.
  12. 39.

    ^

  13. 42.

    GCD

  14. 43.

    # 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 }); });
  15. 46.
  16. 57.
  17. 58.
  18. 64.

    -(NSString *) getBookName { NSString *the_name = @"This is a

    book"; [the_name release]; return the_name; }
  19. 66.

    -(NSString *) getBookName { NSString *the_name = @"This is a

    book"; return [the_name autorelease]; }
  20. 67.
  21. 80.

    // for-loop style NSArray* kids = ... for (int i

    = 0; i < kids.count; ++i) { NSString* kid = [kids objectAtIndex:i]; // do something }
  22. 82.

    // block style NSArray* kids = ... [kids enumerateObjectsUsingBlock:^(NSString* kid,

    NSUInteger idx, BOOL *stop) { // do something here }];
  23. 83.

    NSDictionary * kidsEnglishName = ... NSArray* keys = [dict allKeys];

    for (NSString* key in keys) { NSString* value = [dict objectForKey:key]; // do something else }
  24. 93.
  25. 99.

    高見見龍龍 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 eddie@digik.com.tw +886-928-617-687