Skip to content

Instantly share code, notes, and snippets.

@ttsubono
Created July 10, 2012 06:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttsubono/3081457 to your computer and use it in GitHub Desktop.
Save ttsubono/3081457 to your computer and use it in GitHub Desktop.
setterをoverrideするときの基本的な記述方法
//
// override a setter
//
// NSStringはcopyするという記事もあるが、copyもretainも同じ。
// you do not need to make a copy when Foo is a NSString.
// "copy" and "retain" for NSString are internally the same action.
- (void)setFoo:(Foo *)aFoo {
if (aFoo != foo) {
[foo release];
foo = [aFoo retain];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment