OC Note one: objective-c introduction

Source: Internet
Author: User

1, OC Introduction

Full Name: Objective-c is an object-oriented programming language that expands C and is used primarily for iOS and Mac OS development.

    • On the basis of the C language, a minimal object-oriented syntax is added.
    • Fully compatible with C language
    • You can mix C code, even C + + code, in OC code
    • Applications that can use OC to develop Mac OS x platform and iOS platform
2, OC Grammar Overview

2.1 Key Words

Each language has keywords, such as C language flaot, int and so on, then what are the key words OC?

Basically all keywords start with @

Here are some common keywords, you can preview the first, do not go through the data to find their meaning

@interface, @implementation, @end

@public, @protected, @private, @selector

@try, @catch, @throw, @finally

@protocol, @optional, @required, @class

@property, @synthesize, @dynamic

Self, super, ID, _cmd, __block, __strong, __weak,

2.2 String begins with @

For example @ "Hello" is a string in OC, and "Hello" is a string in C language

2.3 Other grammars

The difference between 2.4 NSLog and printf

    • NSLog receives the OC string as a parameter, printf receives the C language string as a parameter
    • NSLog after output, the set method and get method are not wrapped automatically after printf output
    • #import <Foundation/Foundation.h> required to use NSLog
    • Using printf requires # include <stdio.h>

the role of the 2.5 foundation framework

Develop the necessary framework for OC, IOS, MAC programs

    • This framework contains a number of commonly used APIs (application programming interfaces)
    • The framework contains a lot of header files, if you want to use the contents of the entire framework, including its main header file can be

#import <Foundation/Foundation.h>

3. The difference between OC and other languages

Similarities and differences of 3.1 objective-c with C:

1, c as a structured language, clear level, easy to organize the program in a modular way, easy to debug and maintenance; Objecive-c expands the C language to enable it to have object-oriented design capabilities such as class, message ' inheritance, and C and C + + statements in objective-c code. It can call the C function, or through the C + + object access method;

2, C performance and processing capacity is very strong. Direct access to the physical address of the memory, bit (bit) level of operation, C language implementation of the hardware programming operation, so C language set high-level language and low-level language functions in one-not only for the development of system software, but also suitable for the development of application software; Objective-c can be programmed for the underlying system , on the other hand, can support development with dynamic architectures.

3.2 similarities and differences between OBJECTIVE-C and C + +:

1. Single Inheritance:

Like Java, Smalltalk, OBJECTIVE-C does not support multiple inheritance, while the C + + language supports multiple inheritance.

2. Dynamic:

OBJECTIVE-C is dynamic training (Dynamicaly typed), and its class cubby C + + is easy to operate. Objective-c can allow access to methods and classes based on string names at run time, and can also dynamically connect and add classes.

4. OC Learning Methods

After mastering the C language, it is easier to learn OC. Because OC is an object-oriented language, C language is a process-oriented language, so after learning C, you need to master some object-oriented knowledge. As long as the method is appropriate, progressive learning, you can learn. OC learning can be broadly divided into these areas:

1. Object-Oriented Programming

2. Classes and objects

3. Creating classes and objects

4. Set method and Get method

5. Class methods and Object methods

6, self and other key words

7. Inheritance and polymorphism

8, simple use of strings

9. Classification Category

10. Memory Management

11. Protocol Agent

12. Block

13. Single Case

14. ARC

15, the use of strings

16. Foundation Framework

OC Note one: objective-c introduction

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.