Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Mutator method
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Objective-C=== Using traditional Objective-C 1.0 syntax, with manual reference counting as the one working on [[GNUstep]] on [[Ubuntu version history#1204|Ubuntu 12.04]]: <syntaxhighlight lang="objc"> @interface Student : NSObject { NSString *_name; } - (NSString *)name; - (void)setName:(NSString *)name; @end @implementation Student - (NSString *)name { return _name; } - (void)setName:(NSString *)name { [_name release]; _name = [name retain]; } @end </syntaxhighlight> Using newer Objective-C 2.0 syntax as used in [[Mac OS X 10.6]], [[iOS 4]] and [[Xcode]] 3.2, generating the same code as described above: <syntaxhighlight lang="objc"> @interface Student : NSObject @property (nonatomic, retain) NSString *name; @end @implementation Student @synthesize name = _name; @end </syntaxhighlight> And starting with [[OS X 10.8]] and [[iOS 6]], while using [[Xcode]] 4.4 and up, syntax can be even simplified: <syntaxhighlight lang="objc"> @interface Student : NSObject @property (nonatomic, strong) NSString *name; @end @implementation Student //Nothing goes here and it's OK. @end </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)