"IOS development" "OC" 00, ios "oc 」

Source: Internet
Author: User

"IOS development" "OC" 00, ios "oc 」

 

1. OC Introduction

On the basis of the C language, a minimum object-oriented syntax is added. It is fully compatible with C language. It can be mixed into C language code or even C ++ code in OC code; you can use OC to develop Mac OS X and iOS applications.

Ii. OC syntax Preview

(1) KEYWORDS

Basically, all keywords start with @, such as @ interface @ implementation @ public. A few keywords do not start with @, such as id and _ cmd.

(2) The string starts @

C language string: "hello"

OC language string: @ "hello"

(3) Other syntaxes

Basic types: 5. boolean BOOL (YES/NO) is added ).

Nil is equivalent to null in C, that is, 0.

Screen output: NSLog (@ "hello"); NSLog (@ "age is % d", 2); // line feed

Iii. OC Program Development Process

# The import pre-processing command has two functions: (1) copying the file content, like # include (2) automatically preventing the file content from being repeatedly copied

Program compilation connection process:

Source file (. m) --- (compile) ----> target file (. 0) ----- (Link) ----> executable file (. out)

Foundation framework. It is an essential framework for developing OC, iOS, and Mac programs. To use the content of the entire framework, you can include the main header file of the framework. The main header file is the most important header file in a framework. The main header file name of each framework is the same as that of the framework.

That is: # import <Foundation/Foundation. h>

The running process is as follows:

(1) write the OC source file. m. c

(2) Compile the cc-c xx. m xxx. c file

(3) link to cc xx. o xxx. o-framework Foundation (-framework Foundation is not required if the Foundation framework is not used)

(4) Run./a. out

Iv. BOOL type

Int main ()

{

BOOL B = YES;

BOOL b1 = NO;

BOOL b2 = 1; // YES

BOOL b3 = 2; // NO

NSLog (@ "% I", B );

}

Nature:

Typedef signed char BOOL;

Typedef signed char BOOL

Macro definition:

# Define YES (BOOL) 1

# Define NO (BOOL) 0

Boolean output is generally used as an integer.

 

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.