performSelectorOnMainThread:withObject: waitUntilDone 参数解释
2016-03-05 17:45
483 查看
performSelectorOnMainThread:<#(nonnull SEL)#> withObject:<#(nullable id)#> waitUntilDone:<#(BOOL)#> 前两个参数不解释,最后一个waitUntilDone我看网上很多朋友都在问,解释一下。
在子线程里有如下代码:
主线程更新UI的代码:
这里如果waitUntilDone:NO 即不用等待callBack执行完成,直接执行下面的代码
如果waitUntilDone:YES即需要等待callBack执行完成后,子线程才会继续执行后面的代码
在子线程里有如下代码:
NSLog(@"before"); [self performSelectorOnMainThread:@selector(callBack:) withObject:image waitUntilDone:NO]; NSLog(@"after");
主线程更新UI的代码:
- (void)callBack:(UIImage *)image { NSLog(@"callBack"); imageView.image = image; }
这里如果waitUntilDone:NO 即不用等待callBack执行完成,直接执行下面的代码
如果waitUntilDone:YES即需要等待callBack执行完成后,子线程才会继续执行后面的代码
相关文章推荐
- 关于线程的几个方法的使用说明
- iOS : performSelectorOnMainThread
- 平台:VS2010+object2015(sdk)+zwCAD2015(开发版) 配置
- Any、AnyObject、as
- 【论文学习笔记】Class-Specific Hough Forests For Object Detection
- 让相对定位的层位于object的上面
- Flask--AttributeError 'bool' object has no attribute '__call__'
- Objective-C Runtime 一小时入门教程(上)
- SPRING IN ACTION 第4版笔记-第六章RENDERING WEB VIEWS-006- 使用thymeleaf(TemplateResolver、SpringTemplateEngine、ThymeleafViewResolver、th:include、th:object、th:field="*{firstName}")
- 包装类、object、单例模式、final、抽象类
- Spring MVC 提示: Neither BindingResult nor plain target object for bean
- iOS、OC和Objective-C的区别
- 如何判断List<Object>中是否包含,一个有相同xxx某个属性实体类
- C++中关于静态对象的使用( local static object and global static object)
- C++中关于静态对象的使用( local static object and global static object)
- Object-C官方文档翻译——Block
- Objective的宏到swift中该怎么办?
- 在界面线程不能使用Sleep和WaitForSingleObject之类的函数, 使用 MsgWaitForMultipleObjects
- Objective-C 单例模式
- objective -c之分类,协议。