• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Arc of developer part1
 

Arc of developer part1

on

  • 732 views

 

Statistics

Views

Total Views
732
Views on SlideShare
732
Embed Views
0

Actions

Likes
1
Downloads
12
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Arc of developer part1 Arc of developer part1 Presentation Transcript

    • ARC of a Developer Part.111 11 22
    • Automatic Referrence Counting • Objective-C • - • - retain release • - weak weak referrence11 11 22
    • • • • EXC_BAD_ACCESS •2 release • NSZombie • •11 11 22
    • ARC • GC • • retain/release 2.5 • autoreleasepool 6 • objc_msgSend 33%11 11 22
    • ARC •11 11 22
    • ARC • ARC • LLVM3.0 • -fobjc-arc11 11 22
    • • -fno-objc-arc11 11 22
    • • iOS4 weak reference • __unsafe_unretained • weak reference11 11 22
    • • __strong • __weak • __unsafe_unretained • __autoreleasing •11 11 22
    • Before ARC • • autorelease •11 11 22
    • • • VB6 • COM • Objective-C • • JAVA .NET Obj-C GC11 11 22
    • • NSObject *obj = [[NSObject alloc]init]; * obj NSObject 111 11 22
    • • NSObject *obj = [[NSObject alloc]init]; • NSObject *obj2 = [obj retain]; * obj NSObject 2 * obj211 11 22
    • • NSObject *obj = [[NSObject alloc]init]; • NSObject *obj2 = [obj retain]; • [obj release]; NSObject 1 * obj211 11 22
    • • NSObject *obj = [[NSObject alloc]init]; • NSObject *obj2 = [obj retain]; • [obj release]; • [obj2 release]; NSObject 011 11 22
    • Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } * array NSArray 111 11 22
    • Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } * array NSArray release 1 autorelease pool11 11 22
    • Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } NSArray release 1 autorelease pool11 11 22
    • Autorelease • +(id)array{ NSMutableArray *array = [[[NSMutableArray alloc]init]autorelease]; return array; } NSArray 011 11 22
    • Retain Release Autorerelease • •11 11 22
    • 11 11 22
    • • •11 11 22
    • Xcode Static Analyzer • Xcode Analyze •11 11 22
    • ARC • • Retain Release11 11 22
    • • __strong • __weak • __unsafe_unretained • __autoreleasing11 11 22
    • nil • nil • id __strong obj1; • id __strong obj1 = nil;11 11 22
    • __strong • • id • id test = [[NSObject alloc]init]; • id __strong test = [[NSObject alloc]init]; • retain release • strong11 11 22
    • __strong • dealloc release • release • Retain • Release11 11 22
    • __strong +1 +1 { NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; } • array +1 • array -111 11 22
    • Retain { NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; } @property (nonatomic,retain) NSMutableArray *array; { self.array = [[[NSMutableArray alloc]init]autorelease]; [array addObject:[[[NSObject alloc]init]autorelease]]; [array addObject:[[[NSObject alloc]init]autorelease]]; [array addObject:[[[NSObject alloc]init]autorelease]]; [array addObject:[[[NSObject alloc]init]autorelease]]; }11 11 22
    • Autorelease • Relase +1 +1 { NSMutableArray *array = [[NSMutableArray alloc]init]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; [array addObject:[[NSObject alloc]init]]; }11 11 22
    • • autorelease • autorelease pool +(id)array{ id obj = [[NSMutableArray alloc]init]; return obj; }11 11 22
    • assign __unsafe_unretained copy __strong retain __strong strong __strong unsafe_unretained __unsafe_unretained weak __weak11 11 22
    • strong • release retain •11 11 22
    • 11 11 22
    • • A B C E D11 11 22
    • A B C E D11 11 22
    • A B C assign E D11 11 22
    • @interface Test : NSObject{ id childObject; } -(void)setObject:(id)child; @end { id test1 = [[Test alloc]init]; id test2 = [[Test alloc]init]; [test1 setObject:test2]; [test2 setObject:test1]; }11 11 22
    • { id test1 = [[Test alloc]init]; id test2 = [[Test alloc]init]; [test1 setObject:test2]; [test2 setObject:test1]; } test1 test2 test1 test211 11 22
    • __weak • Retain @interface Test : NSObject{ id __weak childObject; } -(void)setObject:(id)child; @end test1 test211 11 22
    • __weak • nil • test1 test211 11 22
    • __weak +1 id __weak obj = [[NSObject alloc]init]; • delegate11 11 22
    • autorelease pool • • Thread NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; // [pool drain]; @autoreleasepool { // } • LLVM3.0 ARC11 11 22
    • •11 11 22
    • 11 11 22