Skip to content

Instantly share code, notes, and snippets.

@metaskills
Created March 14, 2009 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaskills/79148 to your computer and use it in GitHub Desktop.
Save metaskills/79148 to your computer and use it in GitHub Desktop.
- (id)initWithCoder:(NSCoder *)coder {
if (self = [super initWithCoder:coder]) {
self.teams = [NSMutableArray
arrayWithObjects: @"Anaheim Aardvarks",
@"Baltimore Bats",
@"California Caterpillars",
@"Denver Donkeys",
nil];
self.addButtonItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonWasPressed)]
autorelease];
NSLog(@"teams RC: %d", [self.teams retainCount]);
}
return self;
}
- (void)dealloc {
[teams release];
[addButtonItem release];
[super dealloc];
}
#import <UIKit/UIKit.h>
@interface RootViewController : UITableViewController {
NSMutableArray *teams;
UIBarButtonItem *addButtonItem;
}
@property (nonatomic, retain) NSMutableArray *teams;
@property (nonatomic, retain) UIBarButtonItem *addButtonItem;
- (IBAction)addButtonWasPressed;
@end
NSMutableArray *foo = [NSMutableArray arrayWithObjects:@"one",nil];
NSLog(@"foo RC: %d", [foo retainCount]); // 1
[foo autorelease];
NSLog(@"foo RC: %d", [foo retainCount]); // 1
self.teams = foo;
NSLog(@"foo RC: %d", [foo retainCount]); // 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment