2012-08-16 97 views
0

我在iPhone應用程序中首次使用UIActivityIndi​​catorView,以便讓用戶知道某個過程正在進行中。 爲此,我使用detachNewThreadSelector方法(也是第一次)。UIActivityIndi​​catorView/detachNewThreadSelector

我結束了這樣的代碼:

[myActivityIndicator startAnimating]; 
[NSThread detachNewThreadSelector:@selector(theWorkToBeDone:) toTarget:self withObject:myObject]; 

的問題是,當我的時間申請。當我使用上面的代碼時,執行任務的時間比不使用UIActivityIndi​​catorView和detachNewThreadSelector時長約5倍。 (在這種情況下,用戶仍在等待,但時間較短)。

這是我在使用UIActivityIndi​​catorView時應該期待的時間差異嗎?

或者我是否因爲對UIActivityIndi​​catorView和detachNewThreadSelector缺乏經驗而犯了一些初學者錯誤?

感謝您的任何信息。

回答

0

我剛剛發現,添加此行的一個方法theWorkToBeDone的開頭:

NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init]; 

這一個底:

[pool release]; 

解決我的問題。