"Good Programmer's note sharing" the similarities and differences between OBJ-C and C + + from Hello World

Source: Internet
Author: User

<a href= "http://www.goodprogrammer.org/" target= "blank" >ios training </A>------My obj-c language notes, looking forward to communicating with you!  

#import <foundation/foundation.h>int Main (int argc,const char** argv) {  NSLog (@ "Hello obj-c");  return 0;  }

1. header file:

#import can guarantee that the header file is included only once, regardless of how many times the command actually appears in that file (equivalent to the #ifdef #define in C #endif)

  #import <Foundation/Foundation.h> tell the compiler to view the Foundation.h header file in the Foundation framework

2. Obj-c Style string @:

@ "String" is one of the attributes added by obj-c on standard C, which means that the referenced string should be treated as a nsstring element of the cocoa. (nsstring element "NS" +string).

3, "NS" prefix:

"NS" originates from "NextSTEP" (later renamed to Cocoa); It shows that this function is from cocoa;

Adding a prefix can make the code clearer, readable, and prevent name collisions;

4. NSlog () function:

The printf () output function, similar to C, accepts a string as its first argument, which can contain the format specifier (%s);

"Good Programmer's note sharing" the similarities and differences between OBJ-C and C + + from Hello World

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.