2, the first OC program

Source: Internet
Author: User

method One: Run the first OC program under a MAC terminal1> First install xcode6.1.12> open terminal Tools 3> Use UNIX commands to do the following: attached code (003.M): #import <Foundation/Foundation.h>

int main ()
{//nslog will wrap NSLog after execution (@ "\ n 1th OC Program!!!). ");
return 0;} /* 1. #import的用途:
1>, like # include, copies the contents of a file
3> can automatically prevent the contents of a file from being copied repeatedly

2. #import <Foundation/NSObjCRuntime.h>
Declaration of nslog function in NSObjCRuntime.h

Path to 3.Foundation frame header file
1> Right-click Xcode.app-Show Package Contents
2> xcode.app/contents/developer/platforms/iphoneos.platform/developer/sdks/iphoneos6.0.sdk/system/library/ Frameworks/foundation.framework

4. main header file
1> main header file: The most important header file, the name is usually the same as the frame name, contains all the other header files in the frame
The 2> Foundation Framework's main header file name is Foundation.h 3> only need to contain the foundation framework Master header file, you can use the whole framework of things 4> if you are to apply the standard system functions that Apple provides to you,  Then use the #import < frame name/filename, if you want to refer to other programmers or other code you have written yourself, then use the #import "filename". 5. Running the process (Method 1)
1> writing OC Source files:. M. C
2> compilation: Cc-c xxx.m xxx.c
3> Link: cc XXX.O xxx.o-framework Foundation
(Only the foundation framework is used to add the-framework Foundation)
4> run:./a.out

6. Running the process (Method 2)
1> writing OC source files:. m
2> compilation: CC Xxx.m-framework Foundation-o yyy.out
(Only use the foundation framework to add-framework Foundation, Yyy.out is a UNIX executable) 3> run:./yyy.out */ method Two: Write, compile and run OC program under MAC Terminal1> Open the Mac terminal 2> use the Unix command to do the following to write the command vim 001.m, enter the Vim text editing window 3> write code in vim 4> return to the terminal to compile, run OC program

2, the first OC program

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.