"Programming with objective-c" rule

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.