"Dark Horse Programmer" recognizes OC's first program (OBJECTIVE-C)

Source: Internet
Author: User

Features of OC

● 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

object-oriented versus process-oriented differences:

①oc is Object-oriented

②C is process-oriented

③ object-oriented and facing over-becoming is just two different ways to solve the problem

④-oriented process is only a matter of solving the problem, object-oriented is only to consider the object to solve the problem.

Key Words:

Example: @interface, @implementation, @end

Note: Basically all the keywords start with @

code Exercise (First OC program):

#import <foundation/foundation.h>int Main () {    ///NSLOG output is automatically wrapped    NSLog (@ "First OC program");        return 0;}
1. #import

①, like include, is used to copy the contents of a file

② can automatically prevent file contents from being copied multiple times

the role of the 2.Foundation framework

① the necessary framework for developing OC,IOS,MAC programs

② This framework contains a number of commonly used API (application programming interfaces)

③ Framework contains a lot of header files, if you want to use the entire framework of content, including its header file can--#import <Foundation/Foundation.h>

use of bool:

The nature of the bool type

Tupdef signed Char BOOL;

There are two values for variables of type bool: YES NO

#define YES (BOOL) 1

#define NO (BOOL) 0

Output of bool (As Integer)

NSLog (@ "%d%d", yes,no);

nslog differs from printf:

1.nslog receives the OC string as a parameter. printf receives the C language as a parameter in the string

2.nslog output is wrapped and will not wrap automatically after printf output

3. NSLog #import required to use <foundation/foundation.h>

4. Using printf requires #include<stdio.h>

"Dark Horse Programmer" recognizes OC's first program (OBJECTIVE-C)

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.