IOS SDK 4.3 Study Notes iPhone101 (01)

Source: Internet
Author: User

Prepare for iPad development. Because ios sdk 4.3 is used, the interfaces of many old books do not match this, so I have to read the English description.

 

I watched a small HelloWorld for n hours ...... I have been writing the program for almost 30 years, and I am very ashamed of myself.

 

There are three difficulties:

1. The interface is unfamiliar (ios sdk 4.3 has changed a lot)

2 Language barriers (English is better than the mother tongue)

3. Program Framework (unknown at all)

 

I plan to write some data every day, hoping to help the students who have just started using IOS SDK 4.3.

 

Https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhone101/Articles/00_Introduction.html

IPhone101.pdf

 
P25 has such a statement
@ Synthesize myViewController = _ myViewController;
 
P26:
You use the "_" prefix for the instance variable to serve as a reminder that you shouldn't access an instance variable directly. from an academic perspective, this helps to preserve encapsulation, but there are two important practical benefits in Cocoa:
● Some Cocoa technologies (notably key-value coding) depend on use of accessor methods, and in the appropriate naming of the accessor methods. if you don't use accessor methods, your application may be less able to take advantage of standard Cocoa features.
● Some property values are created on-demand. if you try to use the instance variable directly, you may get nil or an uninitialized value. (A view controller's view is a good example .)
 
In the dictionary, synthesize indicates "synthesis, synthesis, and artificial synthesis"
 
Here, synthesize is used to generate get and set methods. The underlined variable is used only to ensure that the get and set methods are used when using this member variable, rather than directly accessing the variable. You can also write it as follows:
 
@ Synthesize myViewController
 
However, if it is written as above, you cannot literally determine whether to call the get and set methods or directly access the member variables.
 
Self. myViewController = aViewController;
 
If it is written as @ synthesize myViewController = _ myViewController;, it is easy to differentiate.
 
Self. myViewController = aViewController; // use the set Method
Self. _ myViewController = aViewController; // directly access the member variable


From pingjiang2003's column

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.