Skip to content

Instantly share code, notes, and snippets.

@akio0911
Created May 14, 2009 02:10
Show Gist options
  • Save akio0911/111429 to your computer and use it in GitHub Desktop.
Save akio0911/111429 to your computer and use it in GitHub Desktop.
#import <Cocoa/Cocoa.h>
@interface Book : NSObject {
}
- (id)init;
- (void)dealloc;
@end
@implementation Book
- (id)init
{
NSLog(@"Book init");
if(self = [super init]){
}
return self;
}
- (void)dealloc
{
NSLog(@"Book dealloc");
[super dealloc];
}
@end
int main(){
Book * book = [[Book alloc] init];
NSLog(@"count = %d", [book retainCount]);
NSMutableArray * array = [[NSMutableArray alloc] init];
[array addObject:book];
NSLog(@"count = %d", [book retainCount]);
[array release];
NSLog(@"count = %d", [book retainCount]);
[book release];
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment