上一页 1 2 3 4 5 6 7 8 9 ··· 30 下一页

2019年1月19日

摘要: 数据绑定的多种实现方法想法在didSet 方法里,通知观察者支持多个观察者支持取下监听无需显式取消监听,在销毁时自动取消监听代码public final class Box { public typealias Listenr = (T) -> Void private var observers: NSHashTable private var managerKey: Voi... 阅读全文
posted @ 2019-01-19 09:32 花老🐯 阅读(148) 评论(0) 推荐(0) 编辑

2018年12月30日

摘要: 创建ConstraintViewDSL调用UIView 的 snp 方法,生成一个ConstraintViewDSL。注意这个生成的ConstraintViewDSL持有UIView。 创建ConstraintMaker调用makeConstraints,调用ConstraintMaker对应的静态方法。在方法的实现中,创建一个ConstraintMaker。注意这个ConstraintMak... 阅读全文
posted @ 2018-12-30 13:06 花老🐯 阅读(413) 评论(0) 推荐(0) 编辑
摘要: 如图上图所示,居于中心的是ConstraintDescription,它用来生成Constraint,最后再转换成系统的NSLayoutConstraint。 ConstraintDescription包含约束必备的所有因素 internal let item: LayoutConstraintItem internal var attributes: ConstraintAttr... 阅读全文
posted @ 2018-12-30 12:02 花老🐯 阅读(339) 评论(0) 推荐(0) 编辑

2018年12月28日

摘要: 时间顺序如上图:self.latency = initialResponseTime - requestStartTimeself.requestDuration = requestCompletedTime - requestStartTimeself.serializationDuration = serializationCompletedTime - requestCompletedTi... 阅读全文
posted @ 2018-12-28 21:30 花老🐯 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 以DataRequest 为例子。 最简单的返回URLSession 有一个方法,可以构建 URLSessionDataTaskfunc dataTask(with url: URL, completionHandler: @escaping (Data?, URLResponse?, Error?) -> Void) -> URLSessionDataTaskDataRequest 也提供了... 阅读全文
posted @ 2018-12-28 09:01 花老🐯 阅读(267) 评论(0) 推荐(0) 编辑
摘要: AFError is the error type returned by Alamofire. It encompasses a few different types of errors, each with their own associated reasons.使用 AFError 来表示所有的网络错误,分为几大类,每一类又分几小类。AFError 是一个枚举类型!下面就是所有的枚举... 阅读全文
posted @ 2018-12-28 08:55 花老🐯 阅读(203) 评论(0) 推荐(0) 编辑

2018年12月22日

摘要: 以创建一个 DataRequest 为例子发起请求创建 SessionManager顺带也创建了一个 SessionDelegate持有一个urlSession,持有一个串行的 DispatchQueue A。注意,这个不是urlSession 回调方法执行时所在的OperationQueue 创建 Requestable 的 struct,并创建underlying 的 URLSessionD... 阅读全文
posted @ 2018-12-22 21:28 花老🐯 阅读(429) 评论(0) 推荐(0) 编辑

2018年12月18日

摘要: 源码架构Alamofire 的源码包括 Core、Extensions、Features、Supporting Files。其中主要逻辑在 Core里。包括构造请求,发起请求,处理回调等。 Core 的架构Core 中主要有 SessionManager、SessionDelegate、Request和 TaskDelegate 这些类。 SessionManager是一切的起点,它持有一... 阅读全文
posted @ 2018-12-18 00:53 花老🐯 阅读(554) 评论(0) 推荐(0) 编辑

2018年11月10日

摘要: 添加前,网页代码如下: 添加代码 let jsStr = """ function echo(str) {console.log(str);window.webkit.messageHandlers.testecho.postMessage("str");} """ let userScript = WKUserScript.init(source: jsStr, inje... 阅读全文
posted @ 2018-11-10 12:13 花老🐯 阅读(439) 评论(0) 推荐(0) 编辑
摘要: 如上图,是一个十分简单的布局。root view 上加了一个 button 和一个 webview。不加标识符的样子视图层级中没有标识只有 UIView、WKWebView 之类,如果view很多,就很难分得清。约束没有标识符 只知道 uiview 和uibutton 中心对齐,不知道哪个view 和哪个 button。autoLayout 日志中没有标识符(lldb) po [0x7f8a... 阅读全文
posted @ 2018-11-10 09:40 花老🐯 阅读(609) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 30 下一页

导航