上一页 1 2 3 4 5 6 ··· 9 下一页
摘要: enum IntOrString { case IntValue(Int) case StringValue(String) } func mixedType() { let mixed = [IntOrString.IntValue(1), IntOrString.StringValue("string"), ... 阅读全文
posted @ 2018-02-23 10:08 ShellHan 阅读(205) 评论(0) 推荐(0) 编辑
摘要: ?? 对nil进行条件判断 阅读全文
posted @ 2018-02-22 18:20 ShellHan 阅读(110) 评论(0) 推荐(0) 编辑
摘要: class 太长不看版: Delegate关系 1. 子类的 designated init 必须调用父类的 designated init, 并且属于子类但是不属于父类的属性要在super.init()前赋值 2. 子类的 designated init 不能调用父类的 convenience i 阅读全文
posted @ 2018-02-22 17:58 ShellHan 阅读(146) 评论(0) 推荐(0) 编辑
摘要: OC版 // classA.h @property (nonatomic, copy) NSString *testString; //classA.m - (NSString*)testString { if (!_testString) { _testString = @"Hello"; NSL 阅读全文
posted @ 2018-02-22 16:06 ShellHan 阅读(174) 评论(0) 推荐(0) 编辑
摘要: https://www.weheartswift.com/closures/ Currying 柯里化 e.g.1 //返回值为 参数为Int返回值为Int的闭包 func addTo(adder: Int) -> Int -> Int { return { num in return num + 阅读全文
posted @ 2018-02-22 15:27 ShellHan 阅读(143) 评论(0) 推荐(0) 编辑
摘要: PS: 缓存这样写更简单: 阅读全文
posted @ 2018-01-12 22:53 ShellHan 阅读(194) 评论(0) 推荐(0) 编辑
摘要: 解档 存档 阅读全文
posted @ 2017-12-31 20:59 ShellHan 阅读(302) 评论(0) 推荐(0) 编辑
摘要: @weakify _weak _weak @weakify(self); // RAC _weak的self_weak_变量 解决循环引用 问题: weakSelf是弱引用,会被释放 问题: weakSelf是弱引用,会被释放 循环引用的分类 父子对象关系 父子对象关系 当block和闭包包含在类的 阅读全文
posted @ 2017-12-30 21:07 ShellHan 阅读(255) 评论(0) 推荐(0) 编辑
摘要: http://blog.csdn.net/totogo2010/article/details/7839061 https://www.jianshu.com/p/7d32ed28292f Block的本质是可以截取自动变量的匿名函数。 本质和其他变量类似,但是存储的数据是一个函数体。 可以像调用其 阅读全文
posted @ 2017-12-25 17:55 ShellHan 阅读(543) 评论(0) 推荐(0) 编辑
摘要: copy : copy出来的对象都是不可变对象 不可变字符串: copy == retain == 指针拷贝 不会分配内存 可变字符串: copy = alloc + 内存拷贝 重新分配内存 copy出来的都是不可变对象,所以即使是NSMutableString也不能调用可变对象的方法。强制调用会崩 阅读全文
posted @ 2017-12-05 23:03 ShellHan 阅读(140) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 9 下一页