我有一个应用程序可以通过GData ObjC客户端上传到Google Spreadsheets for Mac/iPhone。它工作正常。我试图在自己的线程上获取上传部分,并试图在新线程上调用上传方法。NSThread过早终止
看:
-(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.
}
如果我忘了使用一个单独的线程,一切就像它应该。我是线程编程的新手,所以如果有什么我错过了,请告诉我!
谢谢!
什么是“线程终止,什么都没发生”是什么意思? – 2010-05-29 05:01:03