[Learning notes] [OC language] The first OC program, learning notes oc

Source: Internet
Author: User

[Learning notes] [OC language] The first OC program, learning notes oc

1. # purpose of import:
1> like # include, copy the file content
2> automatically prevents duplicate copies of File Content
 
2. # import <Foundation/NSObjCRuntime. h>
NSObjCRuntime. h contains the NSLog function declaration.
 
3. Path of the header file of the Foundation framework
1> right-click Xcode. app --> display Package content
2> Xcode. app/Contents/Developer/Platforms/iPhoneOS. platform/Developer/SDKs/iPhoneOS6.0.sdk/System/Library/Frameworks/Foundation. framework
 

4. Master header file
1> main header file: The main header file, which is generally the same as the framework name and contains all other header files in the framework.
2> the header file name of the Foundation framework is Foundation. h.
3> you only need to include the main header file of the Foundation framework to use the entire framework.
 
5. Running Process
1> write OC source files:. m,. c
2> compile: cc-c xxx. m xxx. c
3> link: cc xxx. o xxx. o-framework Foundation
(The-framework Foundation must be added only when the Foundation framework is used)
4> Run:./a. out

1 // # include <stdio. h> 2 # import <Foundation/Foundation. h> 3 4 // all use the main function as the entry 5 int main () 6 {7 // printf ("1st OC Programs \ n "); 8 9 // NSLog output content will automatically wrap 10 NSLog (@ "1st OC programs !!! "); 11 12 return 0; 13}

Running result

 

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.