2016年7月17日

摘要: 01 设置imageView的图片 (要引入头文件:#import "UIImageView+WebCache.h") [cell.imageView sd_setImageWithURL:[NSURL URLWithString:app.icon] placeholderImage:[UIImag 阅读全文

posted @ 2016-07-17 23:50 柠檬片 阅读(206) 评论(0) 推荐(0)

摘要: 1 -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event 2 { 3 //1.创建队列 4 NSOperationQueue *queue= [[NSOperationQueue alloc]init]; 阅读全文

posted @ 2016-07-17 17:45 柠檬片 阅读(130) 评论(0) 推荐(0)

摘要: 1.操作依赖 NSOperation之间可以设置依赖来保证执行顺序 比如一定要让操作A执行完后,才能执行操作B,可以这么写 [operationB addDependency:operationA]; // 操作B依赖于操作A 可以在不同queue的NSOperation之间创建依赖关系 注意:不能 阅读全文

posted @ 2016-07-17 17:18 柠檬片 阅读(288) 评论(0) 推荐(0)

摘要: 1.设置最大并发数 什么是并发数 同时执行的任务数 比如,同时开3个线程执行3个任务,并发数就是3 最大并发数的相关方法 - (NSInteger)maxConcurrentOperationCount; - (void)setMaxConcurrentOperationCount:(NSInteg 阅读全文

posted @ 2016-07-17 17:14 柠檬片 阅读(130) 评论(0) 推荐(0)

摘要: NSOperationQueue的作用 NSOperationQueue的作用 NSOperation可以调用start方法来执行任务,但默认是同步执行的 如果将NSOperation添加到NSOperationQueue(操作队列)中,系统会自动异步执行NSOperation中的操作 添加操作到N 阅读全文

posted @ 2016-07-17 16:26 柠檬片 阅读(369) 评论(0) 推荐(0)

摘要: 1.<!--StartFragment-->NSInvocationOperation<!--EndFragment--> 创建NSInvocationOperation对象 - (id)initWithTarget:(id)target selector:(SEL)sel object:(id)a 阅读全文

posted @ 2016-07-17 16:22 柠檬片 阅读(423) 评论(0) 推荐(0)

摘要: NSOperation的作用 NSOperation的作用 配合使用NSOperation和NSOperationQueue也能实现多线程编程 NSOperation和NSOperationQueue实现多线程的具体步骤 先将需要执行的操作封装到一个NSOperation对象中 然后将NSOpera 阅读全文

posted @ 2016-07-17 16:16 柠檬片 阅读(132) 评论(0) 推荐(0)