Created
July 10, 2012 06:03
-
-
Save ttsubono/3081457 to your computer and use it in GitHub Desktop.
setterをoverrideするときの基本的な記述方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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