开发者

Using the DetailView how do I get the selected row value on the DetailViewController.m file?

开发者 https://www.devze.com 2023-01-30 06:40 出处:网络
开发者_Python百科I trying to save my plist after a simple detail change. Here\'s the line that I need fixed.
开发者_Python百科

I trying to save my plist after a simple detail change.

Here's the line that I need fixed.

[plist replaceObjectAtIndex:0 withObject:nameDictionary];

I need to replace the 0 with a variable that gets the row that was selected. Remember, I'm using the codebase from the tutorial above.

something like indexPath.row would be great but I can't get it to work.

My array is no longer accessible on the detail view.


One easy way... Create a NSInterger object in DetailsView.lets say mySelectedIndex

inside RootViewControlle didSelectRowAtIndexPath ..you can access mySelectedIndex

DetailViewController *dvController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];

dvController.mySelectedIndex = indexPath.row;

[self.navigationController pushViewController:dvController animated:YES];

inside DetailsView

[plist replaceObjectAtIndex:mySelectedIndex withObject:nameDictionary];

Second.. Singleton Variable to store the data and access it anywhere in the App.

Third.. Use NSUSerDefaults..

0

精彩评论

暂无评论...
验证码 换一张
取 消