无法在 NSThread 中通过 Twitter-OAuth-iPhone 发布到 twitter
我最近开始使用 Ben Gottlieb 的 Twitter-OAuth-iPhone 类在应用程序中发布状态更新。当在应用程序的主线程上执行时,我已经成功地做到了这一点。但是,当我将其放入“NSThread detachNewThreadSelector”中时,该帖子永远不会出现在 Twitter 上。它处理得很好,我得到了一个正确的[连接标识符],但结果从未出现在 Twitter 上。知道如何让它在线程中运行而不将其返回主线程吗?
已添加代码 Tweet 方法
-(void)tweet{
if([_engine isAuthorized]){
[_engine sendUpdate:@"Tweeting"];
}
}
不起作用:
[NSThread detachNewThreadSelector:@selector(tweet) toTarget:self withObject:nil];
起作用(从主应用程序):
[self tweet];
起作用(从线程内):
[self performSelectorOnMainThread:@selector(tweet) withObject:nil waitUntilDone:NO];
I recently started using Ben Gottlieb's Twitter-OAuth-iPhone class to post status updates in app. I have successfully done so, when executed on the application's main thread. But, when I throw it in a "NSThread detachNewThreadSelector" the post never makes it to twitter. It processes fine and I get a proper [connection identifier], but the results never make it on twitter. Any idea how I can get this to run in a thread without bringing it back to the main thread?
Code added
Tweet method
-(void)tweet{
if([_engine isAuthorized]){
[_engine sendUpdate:@"Tweeting"];
}
}
Doesn't work:
[NSThread detachNewThreadSelector:@selector(tweet) toTarget:self withObject:nil];
Does work (from main app):
[self tweet];
Does work (from within a thread):
[self performSelectorOnMainThread:@selector(tweet) withObject:nil waitUntilDone:NO];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论