iOS Review notes 2:objective-c Grammar basics

Source: Internet
Author: User

A grammatical basis

1 Key Words

Keywords are basically at the beginning of the @, the common keywords are as follows:

@interface, @implement, @end, @public, @private, @selector, @required, @encode, etc.

Other Id,self,super, etc.


2 string begins with @

@ "Hello world!"


3 Boolean type yes/no


4 Null type nil (value 0)


5 other C-language syntax


HelloWorld Program for two OC

Helloworld.m#import <Foundation/NSObjCRuntime.h> #include <stdio.h> int main () {    printf ("OC fully compatible c\n ");    NSLog (@ "Hello world");//auto-wrap    return 0;}


The CC in MAC is used for clang compilation.

Compile:

Cc-c HELLOWORLD.M

A HELLOWOLD.O is generated below the current folder


Link:

CC Hellowork.o-framework Foundataion
A a.out is generated below the current folder

Run:

./a.out

Will print on the screen:

OC fully compatible with C
2015-01-28 19:10:49.451 a.out[503:507] HelloWorld


More than three files

Main.m#import "Helloworld.h" int main () {    show ();    return 0;}

#import <Foundation/NSObjCRuntime.h> #include <stdio.h>//helloworld.hvoid Show () {    printf ("OC fully compatible c\ n ");    NSLog (@ "HelloWorld");}

Compile build. o File:

Cc-c main.m

Link Birth to A.out
CC MAIN.O

Operation mode and result ibid.




iOS Review notes 2:objective-c syntax basics

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.