Are there any Objective-C / Cocoa naming conventions for properties that are acronyms?
Posted
by
t6d
on Stack Overflow
See other posts from Stack Overflow
or by t6d
Published on 2011-01-14T11:21:35Z
Indexed on
2011/01/14
11:53 UTC
Read the original article
Hit count: 207
I have an object that models an online resource. Therefore, my object has to store the URL of the resource it belongs to. How would I name the getter and setter?
MyObject *myObject = [[MyObject alloc] init];
// Set values
[myObject setURL:url];
myObject.URL = url;
// Get values
[myObject URL];
myObject.URL;
or would the following be better:
MyObject *myObject = [[MyObject alloc] init];
// Set values
[myObject setUrl:url];
myObject.url = url;
// Get values
[myObject url];
myObject.url;
The former example would of course require to define the property in the following way:
@property (retain, getter = URL, setter = setURL:) NSURL *url;
© Stack Overflow or respective owner