Objective-c Study Notes (1) Hello world and basics

Source: Internet
Author: User

1. Create a hello WorldProgram

 

1. Start xcode, file-> new project

Select command line utility on the left and foundation tool on the right.

 

2. Compile and run

Click build and go or command + R to compile and run the program.

 

Run-> console, or command + Shift + R, you can open the xcode Console window and see the running result.

 

 

II,CodeBasic

1. You can use # import instead of # include to include header files,

Import will automatically ensure that only one time is included, so you do not need to use # ifdef # endif as # include to ensure that only one time is included.

 

2. nslog (@ "Hello world !")

NS is the prefix of the system class, short for nextstep,

 

2.1. nslog is basically the same as printf in C, but there are some differences.

There are new features, timestamps, date stamps, and automatic attachment line breaks '/N'

 

2.2, @ symbol, the @ symbol before the string. the symbol references the nssting type, which is different from the C-style string.

 

@ Symbol hiding meaning: All @ symbol content marks the extension of objective-C to C Language

 

Nsstring feature: gets the length, which is converted to an integer or floating point number compared with other strings.

Insert a C-style string in nslog with % s, insert nsstring with % @

 

Based on the above information, you can use nslog to implement the hello wrold program.

 

2.3, bool

The bool of objective-C is similar to that of C language, which occupies 1 byte. Use # define, yes is 1, and no is 0.

 

The difference is that non-0 in C is true, and only one byte is recognized,

If 0x3200 is assigned to bool, the result is 0, no, rather than yes.

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.