I have a table view in my XCode (IOS) that is passing data to my second table view
FirstTableViewController.m
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"ShowSecond"]){
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
SecondViewController *List = segue.destinationViewController;
List.cat = [myObjectCat objectAtIndex:indexPath.row];
}
}
SecondTableViewController.h: This is what I have
@property (nonatomic,weak) NSDictionary *cat;
SecondTableViewController.m
for (NSDictionary *clickresult in cat) {
NSString *title_cat = [clickresult objectForKey:@"name"];
NSLog(@"%@", title_cat);
}
When running the code I get the following error:
WebService[7153:90b] 0 WebService[7153:90b] -[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x9ae0 WebService[7153:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKey:]: unrecognized selector sent to instance 0x9ae0'
This is what I see on the left side of the debugger when running the code
cat = (_NSDictionaryl *) class name = _NSDictionaryl
-> [0] = @"name" : @"This is my first title"
-> [1] = @"icon" : @"icon.png"
What do I need to do to get both the name and icon values of the element passed (cat) to the second table view controller?
Any help will be greatly appreciated!
Thanks