OC Basic Notes--Creating a class note and the difference between printf and NSLog (Guangzhou Black Horse Phase I)

Source: Internet
Author: User

1, the Declaration and implementation of the class cannot be nested , the declaration can not nest other declarations, implementation can not nest other implementations

2.declarations of class can only be put in the declaration of member variables and methods

3. The member variable must be declared in curly braces ,

4.You cannot assign a value to a variable at the time of declaration

5, the method can not write curly braces

6. Member variables cannot be defined outside curly braces

7. The method definition must be between the curly braces and the @end

8.object methods can only be called with multiple objects and cannot be called in C language.

9. External cannot recognize @interface and @end functions, but can be placed in @implementation and @end

Thefunction is defined anywhere in the . M file, but is generally not defined in the declaration or implementation of the class

One by one, the implementation can be placed behind the keynote function, as long as the declaration is placed in front of the

One,@interface or @implementation don't forget @end

 1,#import: #include一样都是编译预处理指令#importfunctionality is the same as # include, which copies the contents of the file to the location of the #import Directive#import<> and #include <>is used to include the header file of the system.#import ""with #include "" is used to include header files in your project#importis an # include upgrade that automatically prevents file duplication2, Foundation: is the foundation framework3, @autoreleasepool is an object of memory management (learn)4, the Nslog:foundation framework provides a function for log output NSLog vs. printf1, printf is provided in the C language, and it is in the stdio.h header file2, NSLog is provided by the Foundation framework, NSObjCRuntime.h3, NSLog contains the date of the log output, and the corresponding application4, NSLog line Wrap, at the end \ n is invalid5, the format string in NSLog is not a normal C-language string, NSString object@""It is a literal representation of a NSString object6, all placeholders in printf are supported in OC7, nslog new format character%@ for the output of the object in the main function, Renturn0; indicates that the program exited properly.*/#import<Foundation/Foundation.h>intMainintargcConst Char*argv[]) {printf ("%d,%f,%lf,%c\n",Ten,10.2f,20.2,'A'); NSLog (@"%d,%f,%lf,%c",Ten,10.2f,20.2,'A'); NSLog (@"%@",@"haha"); return 0;}

OC Basic Notes--Creating a class note and the difference between printf and NSLog (Guangzhou Black Horse Phase I)

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.