1, the class name of each class must be unique in the software (including in the framework, bounds), the class name has more than one word is the Hump method.
Prefix |
Framework |
NS
|
Foundation (OS X and IOS) and application Kit (OS X) |
UI
|
UIKit (IOS) |
AB
|
Address Book |
CA
|
Core Animation |
CI
|
Core Image |
2, the name of the method to understand, and in the class is unique, you can also use the Hump method, the first word in lowercase
If the method has a return value, then the first word of the method name implies what will be returned, such as length;
If one of the parameters in the method is error, then this parameter is usually placed after the method name;
As far as possible in the same method only one block, do not have more than one, this can improve reading;
If you add a new method to the existing framework, you need to prefix the method with your own to avoid the name of the method in the frame.
3. Variable names must be unique in the same domain
Try to avoid the following conditions
-(void) SomeMethod { |
int interestingnumber = 42; |
... |
For (NSNumber *eachnumber in array) { |
int interestingnumber = [Eachnumber intvalue]; Not advisable |
... |
} |
} |
4, some specific method names need to follow the specific rules
such as access methods, setter and getter methods, are usually generated automatically by the system itself, and the method name and property name is the same,
FirstName property, setter method: Setfirstname, getter Method: FirstName
However, the BOOL property is obtained in a different way, starting with is, such as the Adjust Boolean property, the Getter method is: Isadjust
5. The object initialization method also must follow certain stipulation
The initialization method name that you create needs to start with INIT, followed by the method name
"Programming with objective-c" rule