我有一个应用程序可以通过 Mac/iPhone 的 GData ObjC 客户端上传到 Google 电子表格。它按原样工作正常。我正在尝试在自己的线程上获取上传部分,并尝试在新线程上调用上传方法。
看:
-(void)establishNewThreadToUpload {
[NSThread detachNewThreadSelector:@selector(uploadToGoogle) toTarget:self withObject:nil];
}
-(void)uploadToGoogle {
NSAutoReleasePool *pool = [[NSAutoReleasePool alloc] init];
//works fine
[helper setNewServiceWithName:username password:password];
//works fine
[helper fetchUserSpreadsheetFeed];
//inside the helper class, fetchUserSpreadsheet feed calls ANOTHER method, which
//calls ANOTHER METHOD and so on, until the object is either uploaded or fails
//However, once the class gets to the end of fetchUserSpreadsheetFeed
//control is passed back to this method, and
[pool release];
//is called. The thread terminates and nothing ever happens.
}
如果我忘记使用单独的线程,一切都会按预期进行。我是线程编程的新手,所以如果我遗漏了什么,请告诉我!
谢谢!