- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我想问一下performSelector:方法需要自己的runloop定时器才能正常工作有什么潜在的原因,因为如果我不专门为他设置一个runloop,他就会辞职!
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan --- %@", [NSThread currentThread]);
dispatch_async((dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)), ^{
[self performSelector:@selector(test) withObject:nil afterDelay:2.0];
/**
* uncomment this line to make it work
*/
// [[NSRunLoop currentRunLoop] run];
});
}
-(void)test
{
NSLog(@"test --- %@", [NSThread currentThread]);
}
最佳答案
我认为您必须需要在 dispatch_async( dispatch_get_main_queue(), ^{});
中调用您的选择器。请看下面的代码。
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSLog(@"touchesBegan --- %@", [NSThread currentThread]);
dispatch_async((dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)), ^{
dispatch_async( dispatch_get_main_queue(), ^{ //ADDED THIS LINE
[self performSelector:@selector(test) withObject:nil afterDelay:2.0];
//[[NSRunLoop currentRunLoop] run];
});//ADDED THIS LINE
});
}
关于ios - 执行选择器 : didn't work properly when using dispatch_async and global_queue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31042855/
我在使用 Typo3 时遇到问题。我可以通过 pagetree 添加新页面、文件夹等,但我无法添加,当我尝试这样做时出现错误: 抱歉,您没有执行此更改的适当权限。 日志中的第二个错误 SQL erro
过去几周我一直在学习 RabbitMQ。我正在尝试使用“ header ”交换来设置决策树类型路由。如果匹配的话我知道如何将其分支出来。但我想要一个“捕获所有”队列,仅当 header 与树中的其他任
我查询: select * from marrydays where YMD_X like '2010-1-%' and marrydays.CONG not like 'aa%'
我尝试发布我的应用程序:http://pomidoro.codeplex.com/在 Windows 应用商店和认证失败,因为:'您的应用不符合要求 1.1。来自测试者的评论:这个应用似乎没有提供值(
在 Django 中,我一直在尝试获取一个搜索字段来对位置进行地理编码,并从我的数据库中吐出一个按距离排序的列表。到目前为止,一切正常,除非我搜索 Google 返回多个结果形式的位置,例如“ann
当我打电话时 运行删除 ,那么它会调用run,那么为什么“ View 没有返回一个HttpResponse对象”发生呢? 谢谢:) View .py def run(request, build):
我的 Django 1.5 应用程序(托管在 webfaction 上)中有自定义用户模型,我得到: AssertionError at /admin/users/user/add/ sensitiv
这是我遇到的错误: View extraio.file_uploader.views.Upload_File 没有返回 HttpResponse 对象。 谁能看出我在这里做错了什么?我似乎无法弄清楚为
我有一个保存表单的简单 View 。代码看起来“干净”,但我无法摆脱错误: "The view didn't return an HttpResponse object." 虽然我在网上搜索过,但我没
在使用 Gradle 导入一堆 (2) 个库后,我在 Logcat 中收到以下错误: https://gist.github.com/devyanlab/1b18fbe67309f3a07d5d 我认
当我尝试多面对话(从 Google Home 切换到 Android Google Assistant)时,我收到“抱歉,我没有得到任何回应”。 我正在使用 Action SDK,语言环境是“ja”。
当我尝试在 Visual Studio python 中运行我的代码时,为什么会收到错误消息“我们没有找到任何解释器”? 最佳答案 您是否安装了合适的 Python 解释器?您安装了它但 Visual
我不明白为什么我会收到这个错误。一个新节点绝对应该能够容纳 pod。因为我只是要求 768Mi 内存和 450m CPU 的数量,并且将自动扩展的实例组的类型为 n1-highcpu-2 - 2 个虚
我正在关注此代码实验室 Facts about You: Build a conversational app for the Google Assistant 我让它工作了一次,但一定是做错了什么,
我在使用 adb 安装命令将一个简单的 APK 安装到模拟器时收到此错误消息:adb install 错误信息: [root@localhost MobileBenchmark]# cd /opt/a
当我使用核心数据将一些从互联网下载的图像保存在 collectionView 单元格中时,出现错误“NSInternalInconsistencyException”,原因:“-[UICollecti
我最近继承了一个实验室 Ubuntu LAMP 服务器,该服务器相对被忽视并且仍在运行 Struts 1.0 应用程序。我们正准备进行全面检修,但与此同时,日志中抛出的唯一错误是 javax.net.
我用谷歌搜索了一下,发现这是 PHP/Apache/MySQL 早期的一个问题,比如 PHP v5.2.4。但是我现在有那个问题,我做错了什么吗?或者有谁可以帮我解决这个问题吗? 日志文件多次打印:
为什么会出现这个错误? Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-
这个问题在这里已经有了答案: Eclipse error "ADB server didn't ACK, failed to start daemon" (23 个回答) Adb won't star
我是一名优秀的程序员,十分优秀!