Summary of Object-C programming:

Source: Internet
Author: User

1, nil, null, nsnull: Nil is used to attach a value to an object. Objects in object-C can be empty, and empty objects can also receive messages. However, the pointer is not allowed to be null. null attaches a value to any pointer. Therefore, null is only used in C or C ++. Nsnull is used for set operations.

2. Set objects in object-C. nsarray is ordered, nsdictionary is a key-value pair, and nsset is unordered. 3. Use the # import pre-compilation command in object-C to avoid repeated references to header files. 4, # pragma mark can be used to separate code blocks to make the Code look clearer. 5. retain and release can increase and decrease the reference count respectively. 6. The nsautoreleasepool is used to manage the automatically released objects in the application. 7. Object-C memory management rules: (1) if you use alloc or copy and new to create an object, you must remember the release object (2) If no object is directly created, do not view the release object (3). If you do not directly create an object, you need to use the object for a long time. Copy or retain object, and retain and release must be consistent. 8. Constant declaration and preprocessing (1) # define kdetailkey @ "detail text" # define down_timeout 60.0 # define safe_release (x) {[x release]; X = nil ;} (2) typedef Enum {ktagseriesview = 100, ktagvideoview} tagsystemviews; (3) Static constant declaration, static nsstring * blockcolor = @ "blockcolor" in the M file "; it is best to put the definition of common constants in a single file During encoding. 9. Use the placeholder % d, % @ to format the string @.

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.