我有一個應用程序可以通過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