摘要:
-(int) f:(int)x;1.这里 - 表示对象方法, +表示类的方法2.参数分割使用 : 号来分开多参数情况:1.函数不带参数 (函数名: f) -(int) f2.带一个参数(函数名 f:x) -(int) f:(int)x 类似c语言中的 int f(int x) 函数3.带两个... 阅读全文
摘要:
@interface Dog: NSObject { @public int age; @protected int ID; @Private float price; }@end字段作用域解析:public: 对象该字段是全局,均可访问protected: 对象该字段是保... 阅读全文
摘要:
创建/销毁 对象:Dog *dog = [Dog alloc]; // 通过alloc创建dog一个这样的对象, alloc相对于C语言中的new // *号既表示指针,也表示引用初始化构造函数:[dog init];销毁对象:[dog release] 阅读全文
摘要:
OC类分为两个文件,一个是.h文件,一个是.m文件 .h文件 存放类,函数的申明 .文件 存放类的具体实现类申明使用关键字 @interface @end来申明类实现使用关键字@implementation @end来实现类声明:#import //相当于c语言的include@interfa... 阅读全文