2011-04-07 68 views
0

在我的AppDelegate中,在啓動屏幕期間,我啓動了一個從互聯網上下載數據的NSThread。 當NSThread完成時,我刪除了啓動畫面。從另一個類的NSThread下載數據後加載數據

我需要在啓動畫面後顯示的視圖,使用下載的數據。 的問題是,該方法

viewWillAppear 

viewDidLoad 

的NSThread中被稱爲...和應用程序可能會崩潰,因爲數據不完全地下載!

這是我的代碼(在appdelegate.m)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
     //... 
     //... 
     NSThread* parse_thread = [[NSThread alloc] initWithTarget:self selector:@selector(carica_dati) object:nil]; 
    [parse_thread start]; 
    return YES; 
} 

-(void)carica_dati{ 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 
    //download data, then remove the splash screen 
    [pool release]; 
    [NSThread exit]; 
} 

我該如何解決呢? 當NSThread完成時(但我需要在另一個類中,我的視圖的類中調用它),可能調用方法?

謝謝!

+0

好的,對不起!解決了!我在nsthread之後添加了主視圖'[self.windows addSubview:tabbar.view]'! – JAA 2011-04-07 18:17:50

回答

0

添加主視圖[self.windows addSubview:tabbar.view]的nsthread後!

;)