在由按鈕激發的方法我把這個代碼:爲什麼viewcontroller屬性沒有設置?
//Get the sVC in order to se its property userLocation
UITabBarController *myTBC = (UITabBarController*)self.parentViewController;
for(UIViewController *anyVC in myTBC.viewControllers) {
if([anyVC.class isKindOfClass:[SecondViewController class]])
self.sVC = (SecondViewController *)anyVC;
[self.sVC setUserLocation:self.userLocation];
NSLog(@"userLocation ISSET to %@ from %@", self.userLocation, sVC.userLocation);
}
控制檯日誌記錄總是正確self.userLocation
值,而不是sVC.userLocation
,它總是出現空。
此方法位於uitabbarcontroller的tab-uiviewcontrollers之一中,而SecondViewController是另一個tab-uiviewcontroller。
爲什麼sVC.userLocation
沒有設置?
VC如何爲userLocation設置屬性? –
在sVC中,它由屬性合成器設置。我不明確地在sVC中設置它,只在fVC中。 – marciokoko