Skip to content

Instantly share code, notes, and snippets.

@TvdW
Created July 9, 2011 01:26
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 TvdW/1073192 to your computer and use it in GitHub Desktop.
Save TvdW/1073192 to your computer and use it in GitHub Desktop.
// In the header file
@property (retain) NSObject *obj;
// In the code
-(id)init {
// WRONG: obj = [[NSData alloc] init]; // This won't call [obj retain]; !!!!
[self setObj:[[NSData alloc] init]]; // CORRECT: [obj retain]; is called properly
return self;
}
-(void)dealloc {
[obj release];
[super dealloc];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment