Learn objective-C (2) together -- Hello World

Source: Internet
Author: User

In the previous section, the hello WorldProgram, Here we will further elaborate on this program,Source codeAs follows:

# Import <Foundation/Foundation. h> int main (INT arvc, char * argv []) {nslog (@ "Hello world! "); Return 0 ;}

1. Objective-C contains the keyword import of the header file, which is mainly because of GCC support and also supports include. The main difference between import and include is that after using import, # ifdef/# define/# endif is not required in the header file to prevent repeated inclusion of header files, which is similar to C # and Java

2. function. h contains all header files.

3. Currently, nslog can be considered as a printf encapsulation, although not so simple

4. The nslog prefix ns is short for nextstep. To prevent conflicts with other function names

5. Cocal is a library with ns as the prefix. Cocal is similar to boost

6. @ indicates that the string needs to be processed as the Cocal nsstring, because the nslog received parameter is nsstring.

Change the source code:

# Include <stdio. h> int main (INT arvc, char * argv []) {printf ("Hello world! "); Return 0 ;}

It can also be compiled. The difference is that nslog outputs a lot of content, such as time information.

Learn objective-C (1) -- install the development environment and hello World in Windows

Learn objective-C (2) together -- Hello World

Learn objective-C (3) together -- How to declare and define classes

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.