SlideShare une entreprise Scribd logo
1  sur  58
Objective-C Survives
       Shumpei Akai
Objective-C

• Objective-C == C + (Smalltalk
    )OOP

• C++ == C + Chaos
Objective-C
•   C

    •   Objective-C++

•
    •       Ruby

    •                   OK

•
•           3

    •
    •
    •
•       C
• Objective-C
•               Cocoa
•
    • gcc
    • clang (LLVM          )

•                   “.m”
•
    • mac     XCode

•
    • Cocoa (mac) / Cocoa Touch (iOS)
    • GNUStep (        )
Objective-C
•   1983:          Brad Cox       (C++   )

•   1988: NeXT (              )


•   1995: NeXT

•   1996: Apple    NeXT

•   2001: Mac OS X

•   2007: Objective-C 2.0
•
    //
      [str length]
    //      1
      [array objectAtIndex:0]
    //     2
     [array insertObject: obj atIndex: 2]
•
    • Ruby Lisp
    • “insertObject:atIndex:”
    • “objectAtIndex:”
•
    • stringByAppendingString:
•
    • setObject:forKey:
•
•
    •
•
    •
id :
※
    Objective-C
• ClassName*   OK

 •
• id
 •
nil
•               (id )

    • null
• nil
 • 0/NULL/nil
 •
NSMutableArray *array =
[NSMutableArray arrayWithObjects: @"one",
@"two”, nil];
NSArray *newAdditions =
[NSArray arrayWithObjects: @"3", @"4", @"5",
nil];

[arry addObjectsFromArray: newAdditions];
BOOL

•
    • C++/C99
•               YES/NO
•                  (.h)
@interface ClassName : SuperClassName {
  id instanceVariable;
}
- (void)instanceMethod;
+ (id)classmethod;
@end
•           (.m)
    @implementation ClassName
    - (void)instanceMethod{
      //
    }

    + (id)classmethod{
      //
    }
    @end
•               (java.lang.Object
      )

    •
    • Cocoa   NSObject

    •
•   java

    •
    •                           2   prefix

    •   apple   NS (== NeXT Step)

    •
•   - (void)instanceMethodWithArg:(id)arg{ }

    •                    Java

    •             self

        •
• obj->instanceVar
 •            (        )

 • self
• @public, @protected, @private
 • @protected               (     )
•   + (void)classMethodWithArg:(id)arg{ }

    •
•               [ClassName methodName]
•   [ClassName class]

    •

    •                   ==



    •   [ClassName foo] == [[ClassName class] foo]
•
    • static
•
+alloc        +allocWithZone:

•
    • Cocoa
    •
    •
- init
    • [[NSObject alloc] init]
       •
       • init
-(id) init{
    self = [super init];
    if(self){
       //
    }
    return self;
}
alloc   init
•
•
•                      ?

    •

    •
Cocoa
•
    •
        • free           retain(+1)

        •            release(-1)

        •        0
•                           caller

          •   alloc,new,copy,mutableCopy

          •                                +1

-(void) doFoo{
  NSString* str=[[NSString alloc] init] ;
  //
    [str release]; //
}
•
        •
- (void)doBarWithArray:(NSArray*)ary{
  id obj=[ary objectAtIndex:0];
  //ary obj release
}
retain
•                    /
        retain

    •

    - (void)doBarWithArray:(NSArray*)ary{
      self->ary = [ary retain];
    }
release
•                       release

    • nil
    - (void)didReceiveMemoryWarning{
      [self->data release];
      self->data = nil; //data free
    }
•                caller

          •   caller   free
-(NSString*) makeString{
  return [[NSString alloc] init] ;
   //caller release
}
                       -(NSString*) makeString{
                         return [[[NSString alloc] init] release];
                          //return
                       }
autorelease
      •           release

          •                                             release

          •                                       obj

-(NSString*) makeString{
  return [[[NSString alloc] init] autorelease];
   //
}
AutoreleasePool
    •   autorelease

        •             =>                              release

        •

- (void)foo{
   NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
   //do something
   [pool release];
}
dealloc
•                        0

    •                        obj
        release

-(void) dealloc{
  [self->str release];
  [self->ary release];
  [super dealloc];
}
•

    • Cocoa
    •
      •       retain

      •       retain
• Java interface
 • optional                               OK
 @protocol HogeProtocol <SuperProtocol>

 -(BOOL)isCharactor;
 -(BOOL)isDisplay;
 -(void)start;
 -(void)abort;
 -(BOOL)step;
 @optional
 -(void)callbackWithData:(NSData*)data;
 @end
• Java
 • id<FooProtocol> : FooProtocol

 • BarClass<FooProtocol>* : BarClass
    FooProtocol
•

    @implementation ClassName(CategoryName)
    - (void)addingMethod{
      //
    }
    @end
•   obj.proptyName

           •

@interface ClassName : NSObject {
}
@property (nonatomic,retain) id prop;   @implementation ClassName
@end                                    @synthesize prop;
                                        @end
•   NSObject

•                                 ?

    •   - (BOOL)respondsToSelector:(SEL)aSelector
•
    •   - (id)performSelector:(SEL)aSelector
    •   - (id)performSelector:(SEL)aSelector withObject:(id)anObject
    •   - (id)performSelector:(SEL)aSelector withObject:(id)anObject
        withObject:(id)anotherObject
(cont.)

•
    • - (IMP)methodForSelector:(SEL)aSelector
•
    •   Class NSClassFromString(NSString *aClassName);
•
    • NSString
      •            @”hoge”;

    • NSMutableString
• Cocoa       mutable         immutable
• NSArray/NSMutableArray
 •                    :

        •     [NSMutableArray arrayWithObjects:@”one”,
              @”two”,nil]

•   Cocoa

    •   nil
/

•
    • NSDictionary/NSMutableDictionary
•
    • NSSet/NSMutableSet
•   NSValue
    •   C

•   NSNumber
    •
    •                  1

        •   [NSNumber numberWithBool:YES]
        •   [NSNumber numberWithInt:0]
        •   [NSNumber numberWithDouble:1.0]
Objective-C


•C
•
•
  •       C
Objective-C




•           OOP

    •
Objective-C


• OS
 •
   •
   •          /
•
• delegate
• target/action
• ARC(Automatic Reference Counting)
• Blocks
• Grand Central Dispatch

Contenu connexe

Tendances

Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CAlexis Gallagher
 
From android/java to swift (3)
From android/java to swift (3)From android/java to swift (3)
From android/java to swift (3)allanh0526
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)Yeshwanth Kumar
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing UpDavid Padbury
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreWeb Zhao
 
ECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
ECMA5 approach to building JavaScript frameworks with Anzor BashkhazECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
ECMA5 approach to building JavaScript frameworks with Anzor BashkhazFITC
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Susan Potter
 
GDG Madrid - Dart Event - By Iván Zaera
GDG Madrid - Dart Event - By Iván ZaeraGDG Madrid - Dart Event - By Iván Zaera
GDG Madrid - Dart Event - By Iván ZaeraJc Miñarro
 
Scala Refactoring for Fun and Profit
Scala Refactoring for Fun and ProfitScala Refactoring for Fun and Profit
Scala Refactoring for Fun and ProfitTomer Gabel
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」techtalkdwango
 
Python internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandPython internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandirpycon
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scalaRuslan Shevchenko
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedSusan Potter
 
Scala introduction
Scala introductionScala introduction
Scala introductionvito jeng
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionDmitry Sheiko
 
Introduction to Type Script by Sam Goldman, SmartLogic
Introduction to Type Script by Sam Goldman, SmartLogicIntroduction to Type Script by Sam Goldman, SmartLogic
Introduction to Type Script by Sam Goldman, SmartLogicSmartLogic
 

Tendances (20)

Swift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-CSwift, functional programming, and the future of Objective-C
Swift, functional programming, and the future of Objective-C
 
From android/java to swift (3)
From android/java to swift (3)From android/java to swift (3)
From android/java to swift (3)
 
RESTful API using scalaz (3)
RESTful API using scalaz (3)RESTful API using scalaz (3)
RESTful API using scalaz (3)
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
Front end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript coreFront end fundamentals session 1: javascript core
Front end fundamentals session 1: javascript core
 
ECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
ECMA5 approach to building JavaScript frameworks with Anzor BashkhazECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
ECMA5 approach to building JavaScript frameworks with Anzor Bashkhaz
 
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
Scalaz By Example (An IO Taster) -- PDXScala Meetup Jan 2014
 
GDG Madrid - Dart Event - By Iván Zaera
GDG Madrid - Dart Event - By Iván ZaeraGDG Madrid - Dart Event - By Iván Zaera
GDG Madrid - Dart Event - By Iván Zaera
 
Java
JavaJava
Java
 
Scala Refactoring for Fun and Profit
Scala Refactoring for Fun and ProfitScala Refactoring for Fun and Profit
Scala Refactoring for Fun and Profit
 
みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」みゆっき☆Think#7 「本気で学ぶJavascript」
みゆっき☆Think#7 「本気で学ぶJavascript」
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
Python internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvandPython internals and how they affect your code - kasra ahmadvand
Python internals and how they affect your code - kasra ahmadvand
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
Functional Algebra: Monoids Applied
Functional Algebra: Monoids AppliedFunctional Algebra: Monoids Applied
Functional Algebra: Monoids Applied
 
Java Script Workshop
Java Script WorkshopJava Script Workshop
Java Script Workshop
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Introduction to Type Script by Sam Goldman, SmartLogic
Introduction to Type Script by Sam Goldman, SmartLogicIntroduction to Type Script by Sam Goldman, SmartLogic
Introduction to Type Script by Sam Goldman, SmartLogic
 
Python Web Tutorial
Python Web TutorialPython Web Tutorial
Python Web Tutorial
 

Similaire à Objective-C Survives

ARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマーARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマーSatoshi Asano
 
오브젝트C(pdf)
오브젝트C(pdf)오브젝트C(pdf)
오브젝트C(pdf)sunwooindia
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev introVonbo
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone developmentVonbo
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたTaro Matsuzawa
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Charles Nutter
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOSPetr Dvorak
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
Arc of developer part1
Arc of developer part1Arc of developer part1
Arc of developer part1Junpei Wada
 
Java & OOP Core Concept
Java & OOP Core ConceptJava & OOP Core Concept
Java & OOP Core ConceptPin-Lun Huang
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical StuffPetr Dvorak
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)Eduard Tomàs
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016Codemotion
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Satoshi Asano
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scalatod esking
 
Mtl LT
Mtl LTMtl LT
Mtl LTaknEp
 

Similaire à Objective-C Survives (20)

ARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマーARCでめちゃモテiOSプログラマー
ARCでめちゃモテiOSプログラマー
 
오브젝트C(pdf)
오브젝트C(pdf)오브젝트C(pdf)
오브젝트C(pdf)
 
iPhone dev intro
iPhone dev introiPhone dev intro
iPhone dev intro
 
Beginning to iPhone development
Beginning to iPhone developmentBeginning to iPhone development
Beginning to iPhone development
 
Node.js extensions in C++
Node.js extensions in C++Node.js extensions in C++
Node.js extensions in C++
 
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみたスマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
スマートフォン勉強会@関東 #11 どう考えてもdisconなものをiPhoneに移植してみた
 
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
Øredev 2011 - JVM JIT for Dummies (What the JVM Does With Your Bytecode When ...
 
MFF UK - Introduction to iOS
MFF UK - Introduction to iOSMFF UK - Introduction to iOS
MFF UK - Introduction to iOS
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Arc of developer part1
Arc of developer part1Arc of developer part1
Arc of developer part1
 
Java & OOP Core Concept
Java & OOP Core ConceptJava & OOP Core Concept
Java & OOP Core Concept
 
Metaprogramming
MetaprogrammingMetaprogramming
Metaprogramming
 
iOS 2 - The practical Stuff
iOS 2 - The practical StuffiOS 2 - The practical Stuff
iOS 2 - The practical Stuff
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
Webエンジニアから見たiOS5
Webエンジニアから見たiOS5Webエンジニアから見たiOS5
Webエンジニアから見たiOS5
 
From Ruby to Scala
From Ruby to ScalaFrom Ruby to Scala
From Ruby to Scala
 
Command Liner with Scala
Command Liner with ScalaCommand Liner with Scala
Command Liner with Scala
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
Mtl LT
Mtl LTMtl LT
Mtl LT
 

Dernier

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Dernier (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Objective-C Survives

  • 1. Objective-C Survives Shumpei Akai
  • 2. Objective-C • Objective-C == C + (Smalltalk )OOP • C++ == C + Chaos
  • 3. Objective-C • C • Objective-C++ • • Ruby • OK •
  • 4. 3 • • • • C
  • 6. • gcc • clang (LLVM ) • “.m”
  • 7. • mac XCode • • Cocoa (mac) / Cocoa Touch (iOS) • GNUStep ( )
  • 8. Objective-C • 1983: Brad Cox (C++ ) • 1988: NeXT ( ) • 1995: NeXT • 1996: Apple NeXT • 2001: Mac OS X • 2007: Objective-C 2.0
  • 9.
  • 10. // [str length] // 1 [array objectAtIndex:0] // 2 [array insertObject: obj atIndex: 2]
  • 11. • Ruby Lisp • “insertObject:atIndex:” • “objectAtIndex:”
  • 12. • stringByAppendingString: • • setObject:forKey: •
  • 13. • • •
  • 14.
  • 15. id :
  • 16.
  • 17. Objective-C
  • 18. • ClassName* OK • • id •
  • 19. nil • (id ) • null • nil • 0/NULL/nil •
  • 20. NSMutableArray *array = [NSMutableArray arrayWithObjects: @"one", @"two”, nil]; NSArray *newAdditions = [NSArray arrayWithObjects: @"3", @"4", @"5", nil]; [arry addObjectsFromArray: newAdditions];
  • 21. BOOL • • C++/C99 • YES/NO
  • 22. (.h) @interface ClassName : SuperClassName { id instanceVariable; } - (void)instanceMethod; + (id)classmethod; @end
  • 23. (.m) @implementation ClassName - (void)instanceMethod{ // } + (id)classmethod{ // } @end
  • 24. (java.lang.Object ) • • Cocoa NSObject •
  • 25. java • • 2 prefix • apple NS (== NeXT Step) •
  • 26. - (void)instanceMethodWithArg:(id)arg{ } • Java • self •
  • 27. • obj->instanceVar • ( ) • self • @public, @protected, @private • @protected ( )
  • 28. + (void)classMethodWithArg:(id)arg{ } • • [ClassName methodName]
  • 29. [ClassName class] • • == • [ClassName foo] == [[ClassName class] foo]
  • 30. • static
  • 31.
  • 32. +alloc +allocWithZone: • • Cocoa • •
  • 33. - init • [[NSObject alloc] init] • • init -(id) init{ self = [super init]; if(self){ // } return self; }
  • 34. alloc init • • • ? • •
  • 35. Cocoa • • • free retain(+1) • release(-1) • 0
  • 36. caller • alloc,new,copy,mutableCopy • +1 -(void) doFoo{ NSString* str=[[NSString alloc] init] ; // [str release]; // }
  • 37. • - (void)doBarWithArray:(NSArray*)ary{ id obj=[ary objectAtIndex:0]; //ary obj release }
  • 38. retain • / retain • - (void)doBarWithArray:(NSArray*)ary{ self->ary = [ary retain]; }
  • 39. release • release • nil - (void)didReceiveMemoryWarning{ [self->data release]; self->data = nil; //data free }
  • 40. caller • caller free -(NSString*) makeString{ return [[NSString alloc] init] ; //caller release } -(NSString*) makeString{ return [[[NSString alloc] init] release]; //return }
  • 41. autorelease • release • release • obj -(NSString*) makeString{ return [[[NSString alloc] init] autorelease]; // }
  • 42. AutoreleasePool • autorelease • => release • - (void)foo{ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; //do something [pool release]; }
  • 43. dealloc • 0 • obj release -(void) dealloc{ [self->str release]; [self->ary release]; [super dealloc]; }
  • 44. • Cocoa • • retain • retain
  • 45. • Java interface • optional OK @protocol HogeProtocol <SuperProtocol> -(BOOL)isCharactor; -(BOOL)isDisplay; -(void)start; -(void)abort; -(BOOL)step; @optional -(void)callbackWithData:(NSData*)data; @end
  • 46. • Java • id<FooProtocol> : FooProtocol • BarClass<FooProtocol>* : BarClass FooProtocol
  • 47. @implementation ClassName(CategoryName) - (void)addingMethod{ // } @end
  • 48. obj.proptyName • @interface ClassName : NSObject { } @property (nonatomic,retain) id prop; @implementation ClassName @end @synthesize prop; @end
  • 49. NSObject • ? • - (BOOL)respondsToSelector:(SEL)aSelector • • - (id)performSelector:(SEL)aSelector • - (id)performSelector:(SEL)aSelector withObject:(id)anObject • - (id)performSelector:(SEL)aSelector withObject:(id)anObject withObject:(id)anotherObject
  • 50. (cont.) • • - (IMP)methodForSelector:(SEL)aSelector • • Class NSClassFromString(NSString *aClassName);
  • 51. • NSString • @”hoge”; • NSMutableString • Cocoa mutable immutable
  • 52. • NSArray/NSMutableArray • : • [NSMutableArray arrayWithObjects:@”one”, @”two”,nil] • Cocoa • nil
  • 53. / • • NSDictionary/NSMutableDictionary • • NSSet/NSMutableSet
  • 54. NSValue • C • NSNumber • • 1 • [NSNumber numberWithBool:YES] • [NSNumber numberWithInt:0] • [NSNumber numberWithDouble:1.0]
  • 56. Objective-C • OOP •
  • 58. • • delegate • target/action • ARC(Automatic Reference Counting) • Blocks • Grand Central Dispatch

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n