Basic differences between OC-related -02:OC and C

Source: Internet
Author: User

Objective:

Process-oriented and object-oriented.

to put it simply, the process is to analyze the steps needed to solve the problem, and then use the function to implement these steps one step at a time, using a single call in turn. Object-oriented is the decomposition of a problem transaction into individual objects, the purpose of which is not to complete a single step, but to describe the behavior of something in the whole process of solving the problem. The difference between the two is that the process is done from the beginning of the thing to the end, whereas object-oriented is to abstract different classes and actions from one event, and then drop the classes into each object. For example, an umbrella on rainy days. The process is: it rained, I built an umbrella and opened it. The object-oriented solution to this problem is: rain, people, umbrellas. It happened when it rained, and the man took an umbrella with him. Obviously, Objective-c is an object-oriented language. The object-oriented concept was added on the basis of inheriting C.





First look at the C and o-c source file differences: The front is C, followed by OC.



Two. Basic syntax comparison:
1 Data types
C Language: basic type (int; short;float;double float ...). Empty type. Pointer type. The constructed type. Defines the type.

OC Language: In addition to the basic data types in C, some other types have been added.


Here are some of the things that need to be highlighted:


1). type bool: Storage 0,1 is true or false. Often used to make logical judgments:

For example, initialize the BOOL type variable Isyes: Yes, then assign the value: No, the NSLog is printed with an integer, the result is 0, and its underlying definition is stored through 0 and one. In addition, there are boolen and bool types in OC, which are similar in function to bool.




2) ID universal pointer, SEL, selector type, and NSObject * Object type, block code blocks, and so on.


2. Keywords
C Language 32 keywords.
OC compatible C Most of the keywords, there are some additions.


3. Process Control statements.  C language in three major structures: (1) sequential structure. (2) Branch structure (3) loop structure.

The structure in OC is the same as C. But it has an enhanced cycle structure, which will be introduced in detail later.


4.o-c unique exception trapping mechanism:






Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Basic differences between OC-related -02:OC and C

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.