Are there Objective-C / Cocoa naming conventions for properties that are acronyms?

I have an object that simulates an online resource. Therefore, my object must store the URL of the resource to which it belongs. What to call getter and setter?

MyObject *myObject = [[MyObject alloc] init];

// Set values
[myObject setURL:url];
myObject.URL = url;

// Get values
[myObject URL];
myObject.URL;

or it will be better:

MyObject *myObject = [[MyObject alloc] init];

// Set values
[myObject setURL:url];
myObject.URL = url;

// Get values
[myObject URL];
myObject.URL;

In the first example, of course, you will need to define a property as follows:

@property (retain, getter = URL, setter = setURL:) NSURL *url;
+3
source share
2 answers

Apple has a list of acceptable abbreviations and abbreviations , where indicated URL. I use myself URL, in accordance with the NSURLRequest, NSURLResponse, NSPersistentStoreetc. (Which have the property URL).

, , camelcase: anURL , anURL ( ).

+4

Apple ... ;)

, url/setURL:

+1

Source: https://habr.com/ru/post/1785412/


All Articles