在由按钮激发的方法我把这个代码:为什么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