Your SlideShare is downloading. ×
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Objective-C Survives
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Objective-C Survives

2,103

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,103
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
13
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
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
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript

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

    ×