I'd like to pass data from MainViewController to specific (It depends on user's choice in GoogleMap) view controller. In MainVC I have NSArray, which is called: userData. The code is:
NSDictionary *tempDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"FirstViewController", @"First",
@"SecondViewController", @"Second",
nil];
NSString *viewControllerIdentifier = [tempDictionary valueForKey:[marker.userData valueForKey:@"controller"]];
UIViewController *destViewController = [iPhoneStoryboard instantiateViewControllerWithIdentifier:viewControllerIdentifier];
//destViewController.placeData = marker.userData;
[self.navigationController pushViewController:destViewController animated:YES];
//destViewController.placeData = marker.userData;
doesn't exist. Should I add this NSArray inside UIViewController implementation? Or any ideas? Thank you, Artem :)
If you are sure that, the viewController instantiate in your storyboard can handle those data, just create your own ViewController Class that manage this NSArray
@interface MyViewController : UIViewController
@property (nonatomic, strong) NSArray placeData;
@end
and in your sample code :
NSDictionary *tempDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
@"FirstViewController", @"First",
@"SecondViewController", @"Second",
nil];
NSString *viewControllerIdentifier = [tempDictionary valueForKey:[marker.userData valueForKey:@"controller"]];
MyViewController *destViewController = (MyViewController *)[iPhoneStoryboard instantiateViewControllerWithIdentifier:viewControllerIdentifier];
destViewController.placeData = marker.userData;
[self.navigationController pushViewController:destViewController animated:YES];
Once this is done, all your viewControllers (assuming there are more than 1) can use this one as mother class
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments