OC高效率52之以ARC簡化引用計數

#import "ViewController.h"
#import "EOCNetworkFetcher.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    /*   ARC下不能調用
     *   retain,release,autorelease,dealloc方法
     *
     *
     */
    
    //用 __weak 局部變量打破  block的保留環
    NSURL *url = [NSURL URLWithString:@"http://wwww.icoding.com"];
    EOCNetworkFetcher *fetcher = [[EOCNetworkFetcher alloc]initWithURL:url];
    EOCNetworkFetcher * __weak weakFetcher = fetcher;
//    [fetcher startWithCompletion:^(BOOL success){
//    
//    }];

    //ARC只負責管理OC對象的內存。尤爲注意CoreFoundation對象不歸ARC管理,開發者必須適時調用CFRetain/CFRelease
    //http://www.cnblogs.com/worldtraveler/p/4585284.html
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
相關文章
相關標籤/搜索