• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
ARCでめちゃモテiOSプログラマー
 

ARCでめちゃモテiOSプログラマー

on

  • 16,211 views

 

Statistics

Views

Total Views
16,211
Views on SlideShare
12,430
Embed Views
3,781

Actions

Likes
26
Downloads
64
Comments
0

22 Embeds 3,781

http://ninjinkun.hatenablog.com 2558
http://d.hatena.ne.jp 731
http://temping-amagramer.blogspot.jp 235
http://wiki.onakasuita.org 91
http://codenote.net 79
http://webcache.googleusercontent.com 34
http://paper.li 9
http://temping-amagramer.blogspot.com 8
https://twitter.com 7
http://a0.twimg.com 7
http://feeds2.feedburner.com 5
https://si0.twimg.com 3
http://temping-amagramer.blogspot.it 3
http://temping-amagramer.blogspot.tw 3
http://hatenatunnel.appspot.com 1
http://localhost 1
http://translate.googleusercontent.com 1
http://temping-amagramer.blogspot.de 1
http://temping-amagramer.blogspot.in 1
http://hisasann.com 1
http://us-w1.rockmelt.com 1
http://temping-amagramer.blogspot.ca 1
More...

Accessibility

Categories

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でめちゃモテiOSプログラマー ARCでめちゃモテiOSプログラマー Presentation Transcript

    • ARC iOS (id:ninjinkun / @ninjinkun)
    • • Cocoa Touch• ARC• ARC•• ARC•• Tips• GC
    • Cocoa Touch • retain / relase -(void)setName:(NSString *)newName { name = [newName retain]; } -(void)dealloc { [name release]; [super dealloc]; 1 3 0 } • Ownership • Ownership retain • Ownership release • 0
    • Cocoa TouchAutorelase • • autorelease • release • / •
    • Cocoa TouchAutorelase • • autorelease • release • / • -(void)buildNewName { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *array = [[[NSMutableArray alloc] init] autorelease]; [array addObject:@"hoge"]; [array addObject:@"fuga"]; [array addObject:@"piyo"]; name =[array componentsJoinedByString:@","]; [pool drain]; }
    • ARC• Automatic Reference Counting•• iOS 5 / Mac OS X 10.7
    • ARC• •• (GC)• Static Analyzer
    • ARC• @interface NonARCObject : NSObject { NSString *name; } -(id)initWithName:(NSString *)name; @end @implementation NonARCObject -(id)initWithName:(NSString *)newName { self = [super init]; if (self) { name = [newName retain]; } return self; } -(void)dealloc { [name release]; [super dealloc]; } @end
    • ARC• @interface ARCObject : NSObject { NSString *name; } -(id)initWithName:(NSString *)name; @end @implementation ARCObject -(id)initWithName:(NSString *)newName { self = [super init]; if (self) { name = newName; } return self; } @end
    • ARCARC • • … • • • •
    • ARC __strong•• Ownership• • retain, release -(void)buildNewName { { __strong NSMutableArray *array = [[NSMutableArray alloc] init]; [array addObject:@"hoge"]; [array addObject:@"fuga"]; [array addObject:@"piyo"]; name =[array componentsJoinedByString:@","]; } } !
    • ARC __strong• • retain, dealloc relase @interface ARCUser : NSObject { __strong NSString *name; } @end @implementation ARCUser -(id)initWithName:(NSString *)newName { self = [super init]; if (self) { name = newName; // [newName retain] } return self; } -(void)dealloc { // [name release] } @end
    • ARC __weak• __weak • • Ownership • nil • • iOS 5 @interface ARCUser : NSObject { __weak id delegate; } @end
    • ARC __unsafe_unretainded• • assign•• iOS 4.3 @interface ARCUser : NSObject { __unsafe_unretained id delegate; } @end
    • ARC __autoreleasing• autorelase•• @autorelasepool { } -(NSArray *)comvertImageToJpeg:(NSArray *)files { NSMutableArray *dataStore = [NSMutableArray array]; @autoreleasepool { for (NSString *filePath in files) { __autoreleasing UIImage *image = [[UIImage alloc] initWithContentsOfFile:filePath]; NSData *data = UIImageJPEGRepresentation(image, 1.0); [dataStore addObject:data]; } } return [dataStore copy]; }
    • ARC• retain, release, autorelase • retainCount• [super dealloc] • dealloc -(void)dealloc { delegate = nil; }• C __bridge NSString *str = @"hogehoge"; CFStringRef strRef = (__bridge CFStringRef)str; CFStringRef strRef = (__bridge_retained CFStringRef)str;
    • • ARC __strong• __strong __strong __strong __strong __strong __strong
    • • iOS 5 __weak• iOS 4.3 __unsafe_unretaind• nil __strong __weak __strong __strong __strong
    • ARC•
    • ARCretain / relase • -S • • _objc_release() • _objc_retain() • _objc_retainAutoreleasedReturnValue()
    • ARC__weak • _objc_storeWeak() • 0 _objc_destroyWeak() • • nil • This document is licensed to ninjin@mac.com.
    • Blocks • ARC • self ? • • release • BlocksKit UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button addEventHandler:^(id sender) { [self showPhotoPickerView]; } forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button];
    • Blocks • UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; __unsafe_unretained id _self = self; // !? [button addEventHandler:^(id sender) { [_self showPhotoPickerView]; } forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button];
    • Blocks • UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; __unsafe_unretained id _self = self; // !? [button addEventHandler:^(id sender) { !? [_self showPhotoPickerView]; } forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button];
    • TipsARC • -fno-objc-arc
    • TipsARC • Static Library • Static Library • Workspace
    • Tips • ARC • iOS 5 __weak • Blocks • UI • UI Blocks
    • GC• GC • iOS •• • CPU
    • • ARC• ( )• __weak• GC • • ( )• ARC