我有2个ViewControllers。我想通过segue将NSArray
转移到另一个。iOS:无法通过segue传递NSArray
我看过所有其他问题,但仍然我的代码无法正常工作。 我想传输matchObject。
Viewcontroller.m
#import "mapViewController.h"
//call map view
-(void) callMap {
[self performSegueWithIdentifier: @"callMap" sender: self];
}
//pass data
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"callMap"]) {
UINavigationController *nc = segue.destinationViewController;
UIViewController *tvc = [nc.viewControllers objectAtIndex:0];
tvc.matchObject = self.matchObject;
}
}
我得到的最后一条语句错误,说财产matchObject没有找到。
我已经定义在 'mapViewController.h'
@property (nonatomic, strong) NSArray *matchObject;
属性和中合成它mapViewController.m'
@synthesize matchObject = _matchObject;
我已经正确连接在故事板的SEGUE。
你确定mapViewController类中的matchObject包含数据吗? –
不,我想将数据传输到mapViewController。 matchObject存在于ViewController中。 –
tvc不能拥有一个matchObject,因为它是一个UINavigationController。你的意思是将它传递给导航控制器的根视图控制器? – rdelmar