2012-01-17 50 views
0

另一個類嘗試推出在NSUrlConection的connectiondidfinish委託方法的視圖 - 控制調用視圖 - 控制從connectiondidfinish委託NSURLConnection的

//Sprequest.m從NSObject的

- (void)connectionDidFinishLoading:(NSURLConnection *)conn {  
    NSLog(@"connectionDidFinishLoading "); 

    if(nStatus == 401) 
    { 
    NSLog(@"called maincontroller to launch dvrview"); 

    MainController *mainview =[[MainController alloc] init]; 
    [mainview reponseFromServer]; 

    }  
} 
//maincontroller.m from viewcontroller 
-(void)reponseFromServer 
{ 
    NSLog(@"response from server - main controller "); 

    dvrView *dvrObj = [[dvrView alloc]initWithNibName:@"dvrView" bundle:nil]; 
    [self.navigationController pushViewController:dvrObj animated:YES]; 
} 

這個DVR觀點犯規得到加載

繼承

回答

2
Sprequest.m is inherited from NSObject , its not a viewController subclass so you cant use 

[self.navigationController pushViewController:dvrObj animated:YES]; 

裏面Sprequest.m 您可以從appdelegate獲取navigationController對象這樣

((AppDelegate *)[UIApplication sharedApplication].delegate).navigationController 

然後用

[((AppDelegate *)[UIApplication sharedApplication].delegate).navigationController pushViewController:dvrObj animated:YES]; 
+0

如何connectiondidfinish完成並準備使用 – Pinky 2012-01-17 13:06:43