-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobjective-c
More file actions
134 lines (103 loc) · 1.76 KB
/
Copy pathobjective-c
File metadata and controls
134 lines (103 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
.h 头文件, 头文件包含类, 方法, 属性的声明
.m/.mm 类的实现文件, 参与编译的文件,用来实现类中声明的方法
数据类型
基本数据类型
整型
短整型(short)
整型(int)
长整型(long)
布尔类型(BOOL)
字符型(char)
实型(浮点型)
单精度(float)
双精度(double)
Block类型
代码块数据类型
结构类型
数组
结构体
枚举
共用体
指针类型
类(class)
id类型
动态对象类型 万能指针
空类型(Void)
特殊类型(SEL, nil)
SEL
选择器数据类型
for(NSString * name in NSArray){
NSLog(@''%@, name)
}
工具箱路径
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOs.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks
#import <Foundation/Foundation.h>
输出
NSLog(@"OC Hello World")
类
// 声明 :NSObject是为了让我们能 实例化 new
@interface Iphone : NSObject
{
@public // 公开的 默认是受保护的
float _model;
int _cpu;
double _size;
int _color;
}
// 行为 () 是用来括住数据类型 - 表示 对象方法 + 表示 类方法
- (void)about;
@end
// 实现
@implementation iphone
// 行为实现
- (void)about
{
_color;
NSLog("啊啊啊");
}
@end
int main(int argc, const char * argv[]) {
// 发送消息 [类名/对象名 方法名]
// 通过iphone 类型的指针接收了 iphone对象的地址
Iphone *p = [Iphone new];
// 属性
p->_model
// 方法
[p about]
return 0;
}
Fundation 框架
关键字
@interface
@implementation
@end
@public
@protected
@private
@selector
@try
@catch
@throw
@finally
@protocol
@optional
@required
@class
@property
@synthesize
@dynamic
BOOL
Class
SEL
YES
NO
id
self
super
nil
atomic
nonatomic
retain
assign
copy
block