Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Conhecendo o ARC

Conhecendo o ARC

Slides mostrados durante a apresentação do primeiro encontro oficial do [Self SP]

Fernando Bass

January 30, 2012
Tweet

More Decks by Fernando Bass

Other Decks in Technology

Transcript

  1. Automatic Reference Counting implements automatic memory management for Objective-C objects

    and blocks, freeing the programmer from the need explicitly insert retains and releases. It does not provide a cycle collector; users must explicitly manage lifetime instead. segunda-feira, 30 de janeiro de 12
  2. Basic rules if you allocate NSMutableArray *mutableArr = [[NSMutableArray alloc]

    init]; [mutableArr addObject:@"first"]; [mutableArr addObject:@"second"]; NSLog(@"Itens of array %@", mutableArr); [mutableArr release]; need release segunda-feira, 30 de janeiro de 12
  3. if not allocate NSMutableArray *mutableArr = [NSMutableArray arrayWithObjects:@"first",@"second", nil]; NSLog(@"Itens

    of array %@", mutableArr); Relax, leave to runtime segunda-feira, 30 de janeiro de 12
  4. The ARC has new rules You no longer need dealloc,

    retain, release, or autorelease retainCount @autoreleasepool blocks NSZones no more :) segunda-feira, 30 de janeiro de 12