- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
如果我在分离线程中使用 performSelectorOnMainThread 调用,主线程何时执行请求?它是在完成当前主线程操作后立即执行此操作,还是存在其他类型的层次结构来确定何时执行 performSelectorOnMainThread 调用?
最佳答案
它在主线程运行循环的下一次迭代时在主线程上执行。
引用 Apple 的文档:
This method queues the message on the run loop of the main thread using the default run loop modes—that is, the modes associated with the NSRunLoopCommonModes constant. As part of its normal run loop processing, the main thread dequeues the message (assuming it is running in one of the default run loop modes) and invokes the desired method.
关于objective-c - performSelectorOnMainThread 调用何时执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3274798/
在解析twitter数据时,我使用线程调用主URL来下载数据。它完美地完成了下载,但是当我在下载数据时按下后退按钮时,它会抛出performSelectorOnMainThread 消息已释放。我知道
我有一个执行一些任务的线程。 最后,我想运行一个选择器来隐藏带有动画的图像。 [self performSelectorOnMainThread:@selector(finishUpdate) wit
我在执行SelectorOnMainThread时遇到问题,它收到“EXC_BAD_ACCESS”。 有什么想法吗? 谢谢 最佳答案 EXC_BAD_ACCESS 是指您不应该访问的内存。 您尚未提供
我的应用程序的委托(delegate)正在调用 didFinishLaunchingWithOptions 方法,效果很好。这个方法里面有一行: [viewController performSele
我正在尝试将 – performSelectorOnMainThread:withObject:waitUntilDone: 用于我在 Swift 中开发的 Cocoa 应用程序。我需要应用程序等到工
为此我大发雷霆,如有任何想法或建议,我们将不胜感激。 我有一个对象,它从子线程自身调用 performSelectorOnMainThread:withObject:waitUntilDone:。这在
我正在尝试在主线程上执行此操作: [curItem.mButton setBackgroundImage:newArt forState:UIControlStateNormal]; 所以我这样做..
我想用这个方法在一个 block 中重新加载我的表数据: import UIKit import AssetsLibrary class AlbumsTableViewController: UITa
内存管理是手动完成的,这个项目中没有使用ARC.. 消息对象是使用 alloc init 创建的,下面的代码在后台线程上被调用。 我在以下调用之前传递了一个消息对象: [self performSe
我设置了一个 UITableView,它应该在从网站加载某些数据后显示一些信息。为了更新 UI 和完成加载数据,我使用了以下方法: performSelectorOnMainThread:@selec
我正在尝试从 didUpdateToLocation 方法调用一个方法,如下所示。在我的 buttonUpdate 方法中,我正在更新界面,并试图避免如果我将代码块直接放在 didUpdateToLo
我有两种方法: -(void)session:(MCSession *)session didStartReceivingResourceWithName:(NSString *)resource
只是遇到了奇怪的事情。我有以下代码: -(void)ImageDownloadCompleat { [self performSelectorOnMainThread:@selector(up
我必须循环执行某些任务的特定方法。我使用了 performselectoronmainthread wait until done 方法。如果我调用它一次,它工作正常。但是当我在 for 循环中调用它
我一直在寻找这个问题的答案,但还没有找到任何答案。我有一个看起来像这样的方法 dispatch_async(dispatch_get_main_queue()) { self.performS
如果我在分离线程中使用 performSelectorOnMainThread 调用,主线程何时执行请求?它是在完成当前主线程操作后立即执行此操作,还是存在其他类型的层次结构来确定何时执行 perfo
想知道是否有人知道 Cocoa 的“performSelectorOnMainThread:”方法的低级实现细节,或者有好的文档的指针。 我最好的猜测,而且我认为可能非常接近,是它使用 mach 端口
我可以在下面的行中调用 pushIncompleteDataToServer。 [sharedDataController performSelectorOnMainThread:@selector(
在我的应用程序中有一个发布选项,用户可以在其中填写信息并将其发送到我的网络服务。 我在模态视图上有“表单”。当触摸取消按钮时,我用来关闭它的功能。 当发布按钮被触摸时,我启动一个线程,而 ws 正在使
如果我用 [self performSelectorOnMainThread:@selector(uploadDidEnd:) withObject:foo waitUntilDone
我是一名优秀的程序员,十分优秀!