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;
Apple has a list of Acceptable Abbreviations and Acronyms, where
URLis listed. I useURLmyself, consistent withNSURLRequest,NSURLResponse,NSPersistentStoreetc (which all have aURLproperty).I think an advantage to using uppercase names is that it works better with camelcase:
anURLlooks better thananUrl(in my opinion).