I have a plist file like this
<array>
<array>
<dict>
<key>name</key>
<string>Ryan</string>
<key>image</key>
<string>088i.png</string>
<key>webSiteURL</key>
<string>http://www.ryan.com</string>
<key>category</key>
<string>Monday</string>
</dict>
</array>
<array>
<dict>
<key>name</key>
<string>Pinky</string>
<key>image</key>
<string>089i.png</string>
<key>webSiteURL</key>
<string>http://www.pinky.com</string>
<key>category</key>
<string>Sunday</string>
</dict>
<dict>
<key>name</key>
<string>Kitty</string>
<key>image</key>
<string>098i.png</string>
<key>webSiteURL</key>
<string>http://www.kitty.com</string>
<key>category</key>
<string>Sunday</string>
</dict>
</array>
</array>
This plist will be load to a NSTableView as a NSMutableArray, Now I want to pass data to DetailView, how to get specific data actually?
I use
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"TableToWebSegue"]) {
NormalDetailView *detailViewController = [segue destinationViewController];
detailViewController.webSiteURL = [[_cellContentList objectAtIndex:indexPath.row] objectForKey:@"webSiteURL"]
} }
But it said indexPath is wrong and should be NSIndexPath, I change it to NSIndexPath but it said .row is wrong…
This is my first app, I have no idea how to get data in this case, if I want get webSiteURL, how to do it? How to pass it to detail view?
If your prepareForSegue method is in the UITableViewController that is you master controller, then just add this line to your prepareForSegue method:
Then, you can use indexPath.row like you have it in your post.
After Edit: In response to your comments, I took a look at your project, and the error is occurring on lis line in NormalViewController:
The problem is, that [_cellContentList objectAtIndex:indexPath.row] is a NormalCategory object which doesn’t have an objectForKey: method. It has a normalList property, which in itself has 2 normalData objects, which in turn have a “name” property. I assume it’s that name property you’re trying to get to, but which one? Since there are 2 normalData objects, you have to have a way to pick which one you want. It seems to me that your data structure is overly complex and confusing (at least to me).