SlideShare a Scribd company logo
Objective-C


      2011 / 3 / 3

     Kenji Kinukawa
=> k.kinukawa, k_kinukawa
2010     11
    =>
2009
       => Trangram
Objective-Cひとめぐり
Objective-Cひとめぐり
Apple




Apple
=>Objective-C




                Objective-C
Objective-C
Objective-C
1983       , Stepstone
1985   NeXT Computer
1995   Next       Stepstone    Obj-C
1997   Apple Next             Jobs
       Mac OS X
2007   iPhone                    Obj-C

                                         -wikipedia
iOS                         Cocoa Touch

      iOS
                                                Cocoa
                UIKit                           Touch


            &

                                   Foundation

Core OS                 &
Objective-C
■

■C

■SmallTalk
■

■for, while, if, switch, C
■
■iOS             GC
           malloc free
■
■
    MyUtil.h
               @interface MyUtil{

               ...
               }

               ...
               @end

    MyUtil.m
               @implementation MyUtil

               ...
               @end
■
MyUtil.h


           @interface MyUtil{
            int hoge;

           }

           -(int)sumAB:(int)a adder:(int)b;
           -(int)diffAB:(int)a differ:(int)b;

           @end
■
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
■


    -(double)evaluation:(int)val
    {
      hoge;
      huga;
      return buzz;
    }
■id
      id
 id




           id obj;
           [obj msg];
■




NSString * obj;
[obj hogehuga];

warning: 'NSString' may not respond to '-hogehuga'
                   NSString -hogehuga
■


         * hoge =
    [[     alloc] init];
■



    [obj msg];
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))
■




    [obj getHoge];
Obj-C
■

    ※



              -(double)evaluation:(int)val;


                      evaluation:
        -(double)evaluation:(int)val max:(int)a;


                  evaluation:max:
■SEL

SEL
SEL



             [obj callHoge];


  SEL action = @selector(callHoge);
  [obj performSelector:action];
■IMP

Obj-C                           C
                      IMP



IMP funcp = [foo methodForSelector:

             @selector(callHoge)];

xyz =
(*funcp)(foo, @selector(callHoge),nil,nil);
■


    Mac Objective-C2.0   GC



      [obj retain];
      [obj release];
■
    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;
}
■


 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
■
             NSString+Parse.h

@interface NSString (Parse)
-(NSDictionary)parseJson:(NSString *)str;
-(NSDictionary)parseXml:(NSString *)str;
-(NSDictionary)parseYaml:(NSString *)str;
@end


[str parseJson:jsonStr];

                   NSString Parse
■

Cocoa


                   A              B

        method A
                       method B
■


               A   B

    method A




    Obj-C
■


                A                        B

    method A                  method A

               delegate
                          B




    Obj-C
■
@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 = @"                      ";

   }
}
■Blocks
Apple                         C                       ISO
LLVM                              iOS4.0
LLVM Compiler 2.0
LLVM
                                               LLVM      2.0
                                                       C Objective-C   C++




LLVM        GCC       2




Xcode 4                                LLVM   IDE
                                     LLVM
                  Xcode IDE                             C C++ Objective-C




                       block lambda
■Blocks
  void (^b)() = ^{
  
 
 printf("im in blockn");
  };
  b();
■Blocks
    void (^b)() = ^{
    
 
 printf("im in blockn");
    };
    b();

    C
Block
                   Block_copy(),Block_release()
iOS4    Blocks




ex)
  GCD(            )
■

    Objective-C
■
    mixi graph API
    mixi graph API       iPhone

                     ※

More Related Content

KEY
Objective-C Crash Course for Web Developers
PDF
C++11 smart pointer
PPT
PPT
C++totural file
ZIP
PDF
Uncommon Design Patterns
PPTX
Smart pointers
PPT
Python Objects
Objective-C Crash Course for Web Developers
C++11 smart pointer
C++totural file
Uncommon Design Patterns
Smart pointers
Python Objects

What's hot (20)

PPTX
What's New in C++ 11/14?
PDF
C++ L01-Variables
PDF
Objective-C Blocks and Grand Central Dispatch
PPT
Cpp tutorial
PDF
JavaScript Design Patterns
PDF
C++ L09-Classes Part2
PPTX
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
PPT
C++: Constructor, Copy Constructor and Assignment operator
PDF
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
PDF
Smart Pointers
PDF
C++ L08-Classes Part1
PDF
JavaScript ES6
PPT
Advance features of C++
TXT
Advance C++notes
PPTX
C# 6.0 Preview
PPTX
Category theory, Monads, and Duality in the world of (BIG) Data
PDF
The Evolution of Async-Programming on .NET Platform (TUP, Full)
PDF
Bind me if you can
PPTX
Алексей Кутумов, Вектор с нуля
PDF
C++ L11-Polymorphism
What's New in C++ 11/14?
C++ L01-Variables
Objective-C Blocks and Grand Central Dispatch
Cpp tutorial
JavaScript Design Patterns
C++ L09-Classes Part2
Lecture 3, c++(complete reference,herbet sheidt)chapter-13
C++: Constructor, Copy Constructor and Assignment operator
The Evolution of Async-Programming on .NET Platform (.Net China, C#)
Smart Pointers
C++ L08-Classes Part1
JavaScript ES6
Advance features of C++
Advance C++notes
C# 6.0 Preview
Category theory, Monads, and Duality in the world of (BIG) Data
The Evolution of Async-Programming on .NET Platform (TUP, Full)
Bind me if you can
Алексей Кутумов, Вектор с нуля
C++ L11-Polymorphism
Ad

Viewers also liked (20)

PDF
20131209_buildinsidermeetup
PDF
サービスを成長させる為の開発について
PDF
いままで使ってきた携帯電話
PDF
Javaone報告会
PPT
Hadoopの紹介
PDF
2014.11.12 ibm bluemix pdf
PDF
New Objective-C Features for Swift 2.0
PDF
CEDEC 2013 - 徹底的にチューンしたハイブリッドアプリ「D.O.T. Defender of Texel」の制作
PDF
Cocos2d-xの深層〜Cocos2d-x組み込みによるピュアAndroid/iOSアプリの外科手術的統合
PPTX
【登壇資料】人類総インターネット時代に20代を無駄にしないために
PDF
Cross2013_DeNA
PDF
PHP at Yahoo! JAPAN
PDF
Rfc768
PPTX
Plannahプロジェクトの開発環境とdeploy gateの紹介
PDF
PHPにおけるI/O多重化とyield
PDF
Swift入門おさらい
PDF
土下座パラダイスはこうして生まれた
PPTX
革新的ブラウザゲームを支えるプラットフォーム技術
PDF
クックパッドでのVPC移行について
PDF
Aerospike deep dive migration
20131209_buildinsidermeetup
サービスを成長させる為の開発について
いままで使ってきた携帯電話
Javaone報告会
Hadoopの紹介
2014.11.12 ibm bluemix pdf
New Objective-C Features for Swift 2.0
CEDEC 2013 - 徹底的にチューンしたハイブリッドアプリ「D.O.T. Defender of Texel」の制作
Cocos2d-xの深層〜Cocos2d-x組み込みによるピュアAndroid/iOSアプリの外科手術的統合
【登壇資料】人類総インターネット時代に20代を無駄にしないために
Cross2013_DeNA
PHP at Yahoo! JAPAN
Rfc768
Plannahプロジェクトの開発環境とdeploy gateの紹介
PHPにおけるI/O多重化とyield
Swift入門おさらい
土下座パラダイスはこうして生まれた
革新的ブラウザゲームを支えるプラットフォーム技術
クックパッドでのVPC移行について
Aerospike deep dive migration
Ad

Similar to Objective-Cひとめぐり (20)

KEY
MacRuby, an introduction
PDF
Iphone course 2
PDF
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
PPTX
C++ via C#
PDF
Boosting Developer Productivity with Clang
PDF
Objective-C Runtime overview
PDF
C++ amp on linux
PDF
Bytes in the Machine: Inside the CPython interpreter
PPTX
Managing console
ZIP
Why MacRuby Matters
PDF
Part II: LLVM Intermediate Representation
PDF
掀起 Swift 的面紗
PDF
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
ZIP
MacRuby to The Max
KEY
Mac ruby to the max - Brendan G. Lim
PDF
iOS for Android Developers (with Swift)
PPTX
PVS-Studio team experience: checking various open source projects, or mistake...
PDF
JIT compilation for CPython
PDF
Is WebAssembly the killer of JavaScript?
PDF
Boyan Mihaylov - Is web assembly the killer of javascript
MacRuby, an introduction
Iphone course 2
"О некоторых особенностях Objective-C++" Влад Михайленко (Maps.Me)
C++ via C#
Boosting Developer Productivity with Clang
Objective-C Runtime overview
C++ amp on linux
Bytes in the Machine: Inside the CPython interpreter
Managing console
Why MacRuby Matters
Part II: LLVM Intermediate Representation
掀起 Swift 的面紗
Value Objects, Full Throttle (to be updated for spring TC39 meetings)
MacRuby to The Max
Mac ruby to the max - Brendan G. Lim
iOS for Android Developers (with Swift)
PVS-Studio team experience: checking various open source projects, or mistake...
JIT compilation for CPython
Is WebAssembly the killer of JavaScript?
Boyan Mihaylov - Is web assembly the killer of javascript

Recently uploaded (20)

PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Mushroom cultivation and it's methods.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
Tartificialntelligence_presentation.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
TLE Review Electricity (Electricity).pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
A Presentation on Artificial Intelligence
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
Getting Started with Data Integration: FME Form 101
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
August Patch Tuesday
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
WOOl fibre morphology and structure.pdf for textiles
Mushroom cultivation and it's methods.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
MIND Revenue Release Quarter 2 2025 Press Release
Tartificialntelligence_presentation.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
cloud_computing_Infrastucture_as_cloud_p
Assigned Numbers - 2025 - Bluetooth® Document
TLE Review Electricity (Electricity).pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
A Presentation on Artificial Intelligence
Zenith AI: Advanced Artificial Intelligence
Getting Started with Data Integration: FME Form 101
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Group 1 Presentation -Planning and Decision Making .pptx
Encapsulation_ Review paper, used for researhc scholars
Enhancing emotion recognition model for a student engagement use case through...
August Patch Tuesday
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf

Objective-Cひとめぐり

  • 1. Objective-C 2011 / 3 / 3 Kenji Kinukawa
  • 2. => k.kinukawa, k_kinukawa 2010 11 => 2009 => Trangram
  • 6. =>Objective-C Objective-C
  • 9. 1983 , Stepstone 1985 NeXT Computer 1995 Next Stepstone Obj-C 1997 Apple Next Jobs Mac OS X 2007 iPhone Obj-C -wikipedia
  • 10. iOS Cocoa Touch iOS Cocoa UIKit Touch & Foundation Core OS &
  • 12. ■ ■for, while, if, switch, C ■ ■iOS GC malloc free
  • 13.
  • 14. MyUtil.h @interface MyUtil{ ... } ... @end MyUtil.m @implementation MyUtil ... @end
  • 15. ■ MyUtil.h @interface MyUtil{ int hoge; } -(int)sumAB:(int)a adder:(int)b; -(int)diffAB:(int)a differ:(int)b; @end
  • 16. ■ 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
  • 17. -(double)evaluation:(int)val { hoge; huga; return buzz; }
  • 18. ■id id id id obj; [obj msg];
  • 19. ■ NSString * obj; [obj hogehuga]; warning: 'NSString' may not respond to '-hogehuga' NSString -hogehuga
  • 20. * hoge = [[ alloc] init];
  • 21. [obj msg];
  • 22. 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))
  • 23. [obj getHoge];
  • 24. Obj-C
  • 25. ※ -(double)evaluation:(int)val; evaluation: -(double)evaluation:(int)val max:(int)a; evaluation:max:
  • 26. ■SEL SEL SEL [obj callHoge]; SEL action = @selector(callHoge); [obj performSelector:action];
  • 27. ■IMP Obj-C C IMP IMP funcp = [foo methodForSelector: @selector(callHoge)]; xyz = (*funcp)(foo, @selector(callHoge),nil,nil);
  • 28. Mac Objective-C2.0 GC [obj retain]; [obj release];
  • 29. 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; }
  • 30. ■ 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
  • 31. NSString+Parse.h @interface NSString (Parse) -(NSDictionary)parseJson:(NSString *)str; -(NSDictionary)parseXml:(NSString *)str; -(NSDictionary)parseYaml:(NSString *)str; @end [str parseJson:jsonStr]; NSString Parse
  • 32. ■ Cocoa A B method A method B
  • 33. A B method A Obj-C
  • 34. A B method A method A delegate B Obj-C
  • 35. ■ @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 = @" "; } }
  • 36. ■Blocks Apple C ISO LLVM iOS4.0 LLVM Compiler 2.0 LLVM LLVM 2.0 C Objective-C C++ LLVM GCC 2 Xcode 4 LLVM IDE LLVM Xcode IDE C C++ Objective-C block lambda
  • 37. ■Blocks void (^b)() = ^{ printf("im in blockn"); }; b();
  • 38. ■Blocks void (^b)() = ^{ printf("im in blockn"); }; b(); C Block Block_copy(),Block_release()
  • 39. iOS4 Blocks ex) GCD( )
  • 40. Objective-C
  • 41. mixi graph API mixi graph API iPhone ※

Editor's Notes