摘要: 1 #import "MyView.h" 2 3 @implementation MyView 4 5 -(instancetype)initWithFrame:(CGRect)frame 6 { 7 if (self = [super initWithFrame:frame]) { 8 _labl 阅读全文
posted @ 2016-01-27 20:12 恒远也 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 1.自定义视图 1 #import "MyView.h" 2 3 @implementation MyView 4 5 6 //重写父类的初始化方法 7 8 -(instancetype)initWithFrame:(CGRect)frame 9 { 10 if(self = [super init 阅读全文
posted @ 2016-01-27 20:06 恒远也 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 1.UIButton的基本设置 1 //创建UIButton 2 UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 3 button.frame = CGRectMake(150, 200, 70,... 阅读全文
posted @ 2016-01-25 19:22 恒远也 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1.创建window 1 //1.创建window,UIScreen是屏幕类,创建和屏幕等大的窗口 2 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 3 //2.背景颜色 4... 阅读全文
posted @ 2016-01-23 21:17 恒远也 阅读(232) 评论(0) 推荐(0) 编辑
摘要: 1 #import "AddressBook.h" 2 #import "Person.h" 3 /* 4 1.为什么下面使用可变数组的时候可以不用初始化直接定义就可以 5 2.为什么要用不可变数组接受返回值 6 3.self的用法,在方法里为什么不能代替_addressBook,而用sel... 阅读全文
posted @ 2016-01-20 23:05 恒远也 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 初始化字符串,方法1(快速初始化) NSString *string0 =@"niahoma"; NSString *string1 =@"niahoma"; //注意:上面的string0 和string1 是指针和内容都 相等 的。 if(string0 == string1){ NSLog... 阅读全文
posted @ 2016-01-20 10:03 恒远也 阅读(1726) 评论(0) 推荐(0) 编辑
摘要: 今天遇到了几个和字符串相关的内存问题,和大家分享一下NSString *name = [[NSString alloc]initWithString:@"张三"];NSLog(@"%d",[name retainCount]);这两行代码的打印结果是-1,NSString * aString = [... 阅读全文
posted @ 2016-01-19 19:20 恒远也 阅读(537) 评论(1) 推荐(0) 编辑
摘要: OC为我们提供了混编模式,我们新建了三个类,Teacher,student,person,可以按照图中的方式找到对应的类来设计不同的管理模式,上边标红的语句是打开自动管理,下边的那一个是关闭自动管理. 阅读全文
posted @ 2016-01-19 17:51 恒远也 阅读(215) 评论(0) 推荐(0) 编辑
摘要: .m文件 1 #import 2 #import "Person.h" 3 int main(int argc, const char * argv[]) { 4 @autoreleasepool { 5 /* 6 KVC:全称Key Value Codi... 阅读全文
posted @ 2016-01-19 17:39 恒远也 阅读(453) 评论(0) 推荐(0) 编辑
摘要: 在MRC模式下,我们建一个Person类的对象.h文件如下 1 #import 2 3 @interface Person : NSObject 4 @property (nonatomic, retain)NSString *name; 5 @property (nonatomic, reta... 阅读全文
posted @ 2016-01-19 17:35 恒远也 阅读(250) 评论(0) 推荐(0) 编辑