摘要: 分类-Category1.基本用途如何在不改变原来类模型的前提下,给类扩充一些方法?有2种方式l 继承l 分类(Category)2. 格式分类的声明@interface类名 (分类名称)// 方法声明@end分类的实现@implementation类名 (分类名称)// 方法实现@end3.好处一... 阅读全文
posted @ 2015-11-10 20:15 yhidr 阅读(242) 评论(0) 推荐(0) 编辑
摘要: id简介万能指针,能指向任何OC对象,相当于NSObject *id类型的定义typedef struct objc_object { Class isa;} *id;使用// 注意:id后面不要加上*id p = [Person new];局限性调用一个不存在的方法,编译器会马上报错构造方法... 阅读全文
posted @ 2015-11-10 19:40 yhidr 阅读(341) 评论(0) 推荐(0) 编辑
摘要: @property1,在@interface中2,自动生成setter和getter的声明#import @interface Person : NSObject{ int _age; // int age; int _height; double _weig... 阅读全文
posted @ 2015-11-10 16:48 yhidr 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 点语法的本质:方法调用#import #import "Person.h"int main(int argc, const char * argv[]){ Person *p = [Person new]; // 点语法的本质还是方法调用 p.age = 10; // [p... 阅读全文
posted @ 2015-11-10 15:11 yhidr 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1.只有利用类名调用类方法的时候,不需要在类名后面写*。其他情况下,类名后面统一加上一个*Circle *c1 = [Circle new];- (BOOL)isInteractWithOther:(Circle *)other;2.返回值是BOOL类型的方法,方法名一般都以is开头- (BOOL)... 阅读全文
posted @ 2015-11-10 13:40 yhidr 阅读(347) 评论(0) 推荐(0) 编辑
摘要: #import @interface Person : NSObject{ int _no; @public // 在任何地方都能直接访问对象的成员变量 int _age; @private // 只能在当前类的对象方法中直接访问 int _h... 阅读全文
posted @ 2015-11-10 12:16 yhidr 阅读(157) 评论(0) 推荐(0) 编辑