SDWebImage 学习一
来源:互联网 发布:java身份证识别技术 编辑:程序博客网 时间:2024/06/01 15:20
知识点
1 dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)
strcmp()
#ifndef dispatch_main_async_safe#define dispatch_main_async_safe(block)\ if (strcmp(dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL), dispatch_queue_get_label(dispatch_get_main_queue())) == 0) {\ block();\ } else {\ dispatch_async(dispatch_get_main_queue(), block);\ }#endif
- strcmp()是c语言的字符串比较函数. strcmp(s1,s2) 判断两个字符串s1和s2是否相同,相同返回true ,不同返回false
- dispatch_queue_get_label 传入DISPATCH_CURRENT_QUEUE_LABEL会返回当前队列.
- 如果是在主线程直接回调, 如果不是主线程, 异步回到主线程.
2
dispatch_get_current_queue
查看原文
Use the dispatch_get_current_queue function for debugging purposes or to test the identity of the current queue. Calling this function from inside a block object returns the queue to which the block was submitted (and on which it is now presumably running). Calling this function from outside of a block returns the default concurrent queue for your application.
返回当前队列的标识, 如果是在代码块内部调用, 返回所在队列, 如果是在代码块外部掉调用, 返回默认并发队列.
3
问题: 如果父类遵守并实现代理方法, 子类不实现, 这时候将子类设置为代理, 那么在调用代理方法时会触发父类实现的方法,会是会报没有实现代理方法错误?
总结: 调用父类 实现的代理方法
问题二: conformsToProtocol
方法怎么用?
总结: 这个方法是在检测, self.delegate是否实现了代理中的方法, 只要实现了其中任意一个都可以返回True.
测试代码
/*测试父类遵守并 实现代理, 子类不实现代理 调用代理会怎么样 经测试, 父类遵守, 父类实现, 子类不实现, 调用代理会 调用父类实现方法 */ ChildClassOne *one = [ChildClassOne new]; self.delegate = one; if ([self.delegate conformsToProtocol:@protocol(TestClassDelegate)]) { NSLog(@"delegate 实现了 代理方法"); [self.delegate testing]; } /* 2017-07-20 10:23:13.420 learnSDWebImage[10055:1305558] delegate 实现了 代理方法 2017-07-20 10:23:13.420 learnSDWebImage[10055:1305558] testing in base class 总结 1. 只要父类实现了 代理 中的任意一个方法 [self.delegate conformsToProtocol:@protocol(TestClassDelegate)] 就会返回 True*/
4. request.HTTPShouldUsePipelining = YES;
查看原文
默认的请求响应该是顺序的,也就是收到响应后, 再请求. 如果这个属性设置为YES, 在还未响应时就可以再次请求, 但是,客户端是无法将请求与响应匹配的, 所以这依赖于服务器, 按照客户端请求的顺序响应.
For pipelining to work, responses must come back in the order they were requested. A naive server implementation might just send the response as soon as it has been calculated. If multiple requests are sent in parallel, and the first request one takes longer to process (e.g. processing a larger image), then the responses will be out of order.
使用Pipelining, 要求响应必须根据请求的顺序返回. 服务器收到请求后会尽快的返回计算结果. 如果并发请求,而且第一个请求很大(比如请求一张大图), 然后响应顺序将会混乱.This is a problem for the client since HTTP is a stateless protocol, the client has no way to match the requests with the responses. It is reliant on the order the responses came back in.
有一个问题是HTTP是无状态协议, 客户端无法将请求和响应正确匹配. 它依赖于响应的顺序.
5
- (nullable NSDirectoryEnumerator<NSURL *> *)enumeratorAtURL:(NSURL *)url includingPropertiesForKeys:(nullable NSArray<NSURLResourceKey> *)keys options:(NSDirectoryEnumerationOptions)mask errorHandler:(nullable BOOL (^)(NSURL *url, NSError *error))handler NS_AVAILABLE(10_6, 4_0);
enumeratorAtURL:includingPropertiesForKeys:options:errorHandler: returns an NSDirectoryEnumerator rooted at the provided directory URL. The NSDirectoryEnumerator returns NSURLs from the -nextObject method. The optional ‘includingPropertiesForKeys’ parameter indicates which resource properties should be pre-fetched and cached with each enumerated URL. The optional ‘errorHandler’ block argument is invoked when an error occurs. Parameters to the block are the URL on which an error occurred and the error. When the error handler returns YES, enumeration continues if possible. Enumeration stops immediately when the error handler returns NO.
If you wish to only receive the URLs and no other attributes, then pass ‘0’ for ‘options’ and an empty NSArray (‘[NSArray array]’) for ‘keys’. If you wish to have the property caches of the vended URLs pre-populated with a default set of attributes, then pass ‘0’ for ‘options’ and ‘nil’ for ‘keys’.
根据你提供的URL, 返回一个迭代器的根节点, 调用nextObject
方法会返回NSURL, keys 参数表明 哪些资源属性应该被预先获取和缓存.errorHandler 当发生错误时调用. 当错误处理返回YES 会继续执行, 返回NO会立即停止.
如果你仅仅获取URL 不想获得其他属性, options传0. 数组传空数组, 如果你想去获得URL默认公开的属性 options 传0, key 传nil
- SDWebImage 学习一
- SDWebImage源码学习之由浅入深一
- SDWebImage学习
- SDWebImage学习
- SDWebImage 学习
- SDWebImage学习
- SDWebImage源代码阅读(一)
- SDWebImage 学习笔记
- SDWebImage原理学习
- SDWebImage学习总结
- SDWebImage源码解析(一)
- 一行行看SDWebImage源码(一)
- SDWebImage 源码阅读(一)
- 第三方框架SDWebImage学习
- [iOS进阶]SDWebImage 学习小结
- iOS客户端学习-SDWebImage
- [ios]iOS开源库学习-SDWebImage
- SDWebImage
- 22. Generate Parentheses
- A
- sql MD5 加密方式
- 时间编程
- tomcat catalina.sh 修改内存 OutOfMemoryError:PermGen space
- SDWebImage 学习一
- Java线程安全性总结
- 刚哥的感情问题2-0J
- UNIX网络编程卷1:套接字联网-第16章:非阻塞式I/O
- 负载均衡器技术Nginx和F5的优缺点对比
- TCP和UDP的区别详解
- 抽象类和接口的对比
- 正则表达式
- 关于current transaction is aborted, commands ignored until end of transaction block与ON_ERROR_ROLLBACK