@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、
比如@"Hello"是OC中的字符串,而"Hello"则是C语言中的字符串
与C语言类似:
跟C语言一样,OC程序的入口依然是main函数,只不过写到一个.m文件中。比如这里写到一个main.m文件中(文件名可以是中文)
#include <stdio.h>
int main()
{
printf("第1个OC程序\n");
return 0;
}
来点跟C语言不一样的,使用NSLog函数输出内容
#import <Foundation/Foundation.h>
int main()
{
NSLog(@"第2个OC程序");
return 0;
}
#ifndef _STDIO_H_
#define _STDIO_H_
#endif
#import <Foundation/Foundation.h>
typedef signed char BOOL;
#define YES (BOOL)1
#define NO (BOOL)0
NSLog(@"%d %d", YES, NO);
跟C语言中多个.c文件的开发是一样的
1) 编写3个文件
#import "one.h"
int main()
{
test();
return 0;
}
void test();
#import <Foundation/Foundation.h>
void test()
{
NSLog(@"调用了test函数");
}
2) 终端指令
1) 编写3个文件
#import "one.h"
int main()
{
test();
return 0;
}
void test();
#include <stdio.h>
void test()
{
printf("调用了test函数\n");
}
2) 终端指令
(没有使用Foundation框架的话,就不用-framework Foundation)
(注:参考于传智)
原文:http://www.cnblogs.com/ljcgood66/p/4966167.html