Objective-Cひとめぐり

9,714 views

Published on

2011/3/3 mixi engineers seminar発表資料。

Published in: Technology
3 Comments
18 Likes
Statistics
Notes
  • Objective-C Programming: The Big Nerd Ranch Guide (2nd Edition) (Big Nerd Ranch Guides) --- http://amzn.to/1R982Rx
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Objective C: Crash Course - The Ultimate Beginner's Course to Learning Objective C Programming in Under 12 Hours --- http://amzn.to/1T2JKuO
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Programming in Objective-C (6th Edition) (Developer's Library) --- http://amzn.to/21Bvido
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
9,714
On SlideShare
0
From Embeds
0
Number of Embeds
3,914
Actions
Shares
0
Downloads
73
Comments
3
Likes
18
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Objective-Cひとめぐり

    1. 1. Objective-C 2011 / 3 / 3 Kenji Kinukawa
    2. 2. => k.kinukawa, k_kinukawa2010 11 =>2009 => Trangram
    3. 3. AppleApple
    4. 4. =>Objective-C Objective-C
    5. 5. Objective-C
    6. 6. Objective-C
    7. 7. 1983 , Stepstone1985 NeXT Computer1995 Next Stepstone Obj-C1997 Apple Next Jobs Mac OS X2007 iPhone Obj-C -wikipedia
    8. 8. iOS Cocoa Touch iOS Cocoa UIKit Touch & FoundationCore OS &
    9. 9. Objective-C■■C■SmallTalk
    10. 10. ■■for, while, if, switch, C■■iOS GC malloc free
    11. 11.
    12. 12. ■ MyUtil.h @interface MyUtil{ ... } ... @end MyUtil.m @implementation MyUtil ... @end
    13. 13. ■MyUtil.h @interface MyUtil{ int hoge; } -(int)sumAB:(int)a adder:(int)b; -(int)diffAB:(int)a differ:(int)b; @end
    14. 14. ■MyUtil.m @implementation MyUtil -(int)sumAB:(int)a adder:(int)b { return a+b; } -(int)diffAB:(int)a differ:(int)b { return a-b; } @end
    15. 15. ■ -(double)evaluation:(int)val { hoge; huga; return buzz; }
    16. 16. ■id id id id obj; [obj msg];
    17. 17. ■NSString * obj;[obj hogehuga];warning: NSString may not respond to -hogehuga NSString -hogehuga
    18. 18. ■ * hoge = [[ alloc] init];
    19. 19. ■ [obj msg];
    20. 20. SICP(define (fact n) (if (= n 1) 1 (* (fact (- n 1)) n)))(define (fact2 n) (define (in-fact n ans) (if (= n 1) ans (in-fact (- n 1) (* ans n)))) (in-fact n 1))(define (fact3 n) (define (fact2-iter n ans) (if (= n 0) ans (fact2-iter (- n 1) (* n ans)))) (fact2-iter n 1))(print (fact3 12000))
    21. 21. ■ [obj getHoge];
    22. 22. Obj-C
    23. 23. ■ ※ -(double)evaluation:(int)val; evaluation: -(double)evaluation:(int)val max:(int)a; evaluation:max:
    24. 24. ■SELSELSEL [obj callHoge]; SEL action = @selector(callHoge); [obj performSelector:action];
    25. 25. ■IMPObj-C C IMPIMP funcp = [foo methodForSelector: @selector(callHoge)];xyz =(*funcp)(foo, @selector(callHoge),nil,nil);
    26. 26. ■ Mac Objective-C2.0 GC [obj retain]; [obj release];
    27. 27. ■ interface @protocol MGVoiceClientDelegate<NSObject> -(void)mgVoiceClient:(NSURLConnection *)conn didReceiveResponseError:(NSString *)error; -(void)mgVoiceClient:(NSURLConnection *)conn didFailWithError:(NSError*)error; -(void)mgVoiceClient:(NSURLConnection *)conn didFinishGetting:(NSArray *)voices; -(void)mgVoiceClient:(NSURLConnection *)conn didFinishPosting:(id)reply; @end@interface VoiceTableViewController : UITableViewController <MGVoiceClientDelegate>{ MGVoiceClient * voiceClient; NSArray * voiceArray;}
    28. 28. ■ Not NSString+Parse.h@interface NSString (Parse)-(NSDictionary)parseJson:(NSString *)str;-(NSDictionary)parseXml:(NSString *)str;-(NSDictionary)parseYaml:(NSString *)str;@end[str parseJson:jsonStr]; NSString Parse
    29. 29. ■ NSString+Parse.h@interface NSString (Parse)-(NSDictionary)parseJson:(NSString *)str;-(NSDictionary)parseXml:(NSString *)str;-(NSDictionary)parseYaml:(NSString *)str;@end[str parseJson:jsonStr]; NSString Parse
    30. 30. ■Cocoa A B method A method B
    31. 31. ■ A B method A Obj-C
    32. 32. ■ A B method A method A delegate B Obj-C
    33. 33. ■@protocol MGVoiceDelegate;@interface MGVoice : NSObject{@public id <MGVoiceDelegate> delegate;}@end-(void)mgCommentClient:(NSURLConnection *)conn didFinishGetting:(NSArray *)commentArray{ if([delegate respondsToSelector:@selector(mgVoice:didFinishGettingComments:)]){ [delegate mgVoice:conn didFinishGettingComments:commentArray]; }}- (void)viewDidLoad { [super viewDidLoad]; voice.delegate = self;}-(void)mgVoice:(NSURLConnection *)conn didFinishGettingComments:(NSArray *)commentArray{ if([commentArray count]>0){ MGComment * comment = [commentArray objectAtIndex:0]; commentText.text = comment.commentText; }else{ commentText.text = @" "; }}
    34. 34. ■BlocksApple C ISOLLVM iOS4.0LLVM Compiler 2.0LLVM LLVM 2.0 C Objective-C C++LLVM GCC 2Xcode 4 LLVM IDE LLVM Xcode IDE C C++ Objective-C block lambda
    35. 35. ■Blocks void (^b)() = ^{ printf("im in blockn"); }; b();
    36. 36. ■Blocks void (^b)() = ^{ printf("im in blockn"); }; b(); CBlock Block_copy(),Block_release()
    37. 37. iOS4 Blocksex) GCD( )
    38. 38. ■ Objective-C
    39. 39. ■ mixi graph API mixi graph API iPhone ※

    ×