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