上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 167 下一页
摘要: 虚线是isa的指向,实线是继承关系。 阅读全文
posted @ 2017-08-23 14:44 无天666 阅读(193) 评论(0) 推荐(0)
摘要: // Person.h #import @interface Person : NSObject @property int age; /* 什么是类工厂方法: 用于快速创建对象的类方法, 我们称之为类工厂方法 类工厂方法中主要用于 给对象分配存储空间和初始化这块存储空间 规范: 1.一定是类方法 + 2.方法名称以类的名称开头, 首字母小写 3.一定有返回值, 返回... 阅读全文
posted @ 2017-08-23 14:01 无天666 阅读(369) 评论(0) 推荐(0)
摘要: // // Person.h #import @interface Person : NSObject @property int age; @property double width; /* 什么是类工厂方法: 用于快速创建对象的类方法, 我们称之为类工厂方法 类工厂方法中主要用于 给对象分配存储空间和初始化这块存储空间 规范: 1.一定是类方法 + 2.方法名称以... 阅读全文
posted @ 2017-08-23 13:59 无天666 阅读(239) 评论(0) 推荐(0)
摘要: // // Person.h #import @interface Person : NSObject @property int age; @property NSString *name; /* 自定义构造方法: 其实就是自定义一个init方法 1.一定是对象方法 2.一定返回id/instancetype 3.方法名称一定以init开头 */ - (instancety... 阅读全文
posted @ 2017-08-23 11:36 无天666 阅读(241) 评论(0) 推荐(0)
摘要: // // Person.h #import @interface Person : NSObject @property int age; @property NSString *name; /* 自定义构造方法: 其实就是自定义一个init方法 1.一定是对象方法 2.一定返回id/instancetype 3.方法名称一定以init开头 */ - (instancet... 阅读全文
posted @ 2017-08-23 11:34 无天666 阅读(219) 评论(0) 推荐(0)
摘要: // Person.h #import @interface Person : NSObject @property int age; - (void)test:(id)obj1; //编译不报错 - (void)demo:(instancetype)obj2; //不能定义变量,不能定义形参数 @end // // Person.m #import "Person.h" ... 阅读全文
posted @ 2017-08-23 11:11 无天666 阅读(224) 评论(0) 推荐(0)
摘要: // Person.h #import @interface Person : NSObject @property int age; //属性是_age @end // // Person.m #import "Person.h" @implementation Person - (instancetype)init { if (self = [super in... 阅读全文
posted @ 2017-08-23 10:33 无天666 阅读(204) 评论(0) 推荐(0)
摘要: // // Person.h #import @interface Person : NSObject @property int age; @end // // Person.m #import "Person.h" @implementation Person /* // 重写init方法, 在init方法中初始化成员变量 // 注意: 重写init方法必须按照苹果规定... 阅读全文
posted @ 2017-08-23 10:31 无天666 阅读(163) 评论(0) 推荐(0)
摘要: // // main.m // new方法实现原理 #import #import "Person.h" int main(int argc, const char * argv[]) { /* new做了三件事情 1.开辟存储空间 + alloc 方法 2.初始化所有的属性(成员变量) - init 方法 3.返回对象的地址 ... 阅读全文
posted @ 2017-08-23 10:15 无天666 阅读(172) 评论(0) 推荐(0)
摘要: // // Person.h #import @interface Person : NSObject - (void)sleep; @property int age; @end // // Person.m #import "Person.h" @implementation Person - (void)sleep { NSLog(@"人睡觉"); ... 阅读全文
posted @ 2017-08-23 10:00 无天666 阅读(256) 评论(0) 推荐(0)
上一页 1 ··· 63 64 65 66 67 68 69 70 71 ··· 167 下一页