(2/18) retake Standford_iOS7 development _ Xcode _ course notes, xcode6ios7 Simulator

Source: Internet
Author: User

(2/18) retake Standford_iOS7 development _ Xcode _ course notes, xcode6ios7 Simulator

Lesson 2:

1. inert Initialization

1 -(ObjectType *)example2 {3     f(!_example) example =[[ObjectType alloc] init];4 5     return _example;6 }

The variable is not initialized until the last moment before use.

2. array literal format

@ [A, B, c ,..., M, n];

3. @ synthesize

When the setter and getter methods of the property are rewritten at the same time, they must be explicitly merged; otherwise, the compiler will generate @ synthesize example = _ example by default;

4. Class Methods

1 + (ReturnType *) example2 {3 // class attributes cannot be used in class methods 4 // used as factory methods 5 // generally used to create instance objects 6}

5. object initialization method

Framework:

1-(instancetype) init2 {3 self = [super init] 4 if (self) 5 {6 // custom initialization content 7} 8 return self; 9}

Specify the initialization method:

The default value is public API, that is, the initialization method used. You must call the specified Initialization Method in other initialization methods to complete the initialization. There is no syntax format, which is usually explained through annotations. Similarly, a method is specified for a class of methods.

6. basic use of Xcode

For details, see the video or courseware pdf.

7. Outlet and Action

The link between the UI and Controller is implemented by pressing Ctrl + Drag.

IBAction is actually void for Xcode to identify and the compiler automatically ignores it.

IBOutlet is actually a tag for Xcode to identify and the compiler automatically ignores it.

1 # define IBAction void 2 # define IBOutlet

8. NSLog ()

C language function, used to print output on the console, can be used for testing when the program is running,

(Note: When writing an APP, we do not directly use the NSLog () function, because the NSLog () output is not allowed during APP packaging and compilation, therefore, we need to use NSLog () in the debug version through pre-compilation, and cancel NSLog () in the release version (). You can insert the following code in the pch file or in a proper place:

1 #if DEBUG2 #define yourPrefixLog(...) NSLog(__VA_ARGS__)3 #else4 #define yourPrefixLog(...)5 #endif

Then, you can directly use yourPrefixLog () to replace the previous NSLog () where the program needs to print the output .)

9. Job

A. Use Xcode to create a Matchismo Project

B. Create and enter four previous objective-C classes: Card, PlayingCard, Deck, PlayingCardDeck

C. Add a private attribute of the Deck Class to ViewController.

D. Use inertia to initialize the above attributes and initialize Deck as a card heap containing PlayingCard.

E. Implement random turning of a card in the heap of each click card

F. The original function structure cannot be damaged.

For more information, see the https://github.com/NSLogMeng/Stanford_iOS7_Study_Machismo (this assignment answer for the course published the correct answer, follow-up course assignments no standard answer, the author only for personal understanding answer, welcome to correct)

 

Course video address: Netease Open Class: http://open.163.com/movie/2014/1/H/R/M9H7S9F1H_M9H7V38HR.html

Or use iTunes U to search for standford courses

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.