我正在做一些需要在第二个控制器上的plist
上显示Label
数据的内容。当我点击第一个控制器上的TableView
时,似乎我无法通过segue传递它。有没有办法将数据传递给下一个ViewController?
我刚刚为plist
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_theTableView.dataSource=self;
_theTableView.delegate=self;
NSString* path = [[NSBundle mainBundle] pathForResource:@"theplist.plist" ofType:@""];
array1 = [[NSArray alloc] initWithContentsOfFile:path];
}
和tableview
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [array1 count];
}
和segue
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReusedCell"];}
NSDictionary*item = array1[indexPath.row];
cell.textLabel.text = [item objectForKey:@"movien"];
return cell;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showDetail"])
{
NSIndexPath *indexPath = [_myTableView indexPathForSelectedRow];
NSString *object = tableObjects[indexPath.row];
DetailViewController *controller = (DetailViewController *)[segue destinationViewController];
[controller setDetailItem:object];
}
}