2016-07-20 2 views
0

이전에는 결코 발생하지 않았기 때문에 내 견과류가되었습니다. 수십 번이 작업을 수행했습니다.보기 컨트롤러 사이를 통과 할 때의 Null 값

두 개의보기 컨트롤러간에 값을 전달하면 NULL 값이됩니다.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if ([segue.identifier isEqualToString: @"LoginSegue"]) { 
     UITabBarController *destinationTabController = [segue destinationViewController]; 
     ViewController *destinationViewController = destinationTabController.selectedViewController; 
     NSLog(@"Logged user is %@.", loggedUser); //This prints out the user correctly 
     destinationViewController.currentUser = loggedUser; 
    } 
} 

그러나 SEGUE가 나는 currentUser 값을 로그온을 시도 수행하고 NULL있을 때 :

은 내가 prepareForSegue: 방법이있다.

의견이 있으십니까?

+0

'destinationViewController'를 로깅 해보십시오. – matt

+0

그래, 난 바보 야. 그것은 null이었다. 그것을 (지금은) [destinationTabController viewController] objectAtIndex : 0]으로 변경하면 문제가 해결되었습니다. – Ancinek

+0

:) 무언가가 작동하지 않을 때는 언제든지 로그 아웃하십시오. Objective-C는 일이 0 일 때 barf를하지 않으므로 항상 원인이 될 수 있습니다. 스위프트로 전환하는 또 다른 멋진 이유가 있습니다. – matt

답변

2

탭 막대 컨트롤러가 인터페이스에 없으므로 아무 것도 선택되지 않습니다. 그러므로 destinationViewControllernil이고, currentUser을 설정하려는 시도는 없습니다.

관련 문제