Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c XCode NSDictionary错误-objectForKey::发送到实例的选择器无法识别_Objective C_Xcode_Web Services_Uitableview - Fatal编程技术网

Objective c XCode NSDictionary错误-objectForKey::发送到实例的选择器无法识别

Objective c XCode NSDictionary错误-objectForKey::发送到实例的选择器无法识别,objective-c,xcode,web-services,uitableview,Objective C,Xcode,Web Services,Uitableview,我的XCode(IOS)中有一个表视图,它将数据传递给我的第二个表视图 FirstTableViewController.m - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if([segue.identifier isEqualToString:@"ShowSecond"]){ NSIndexPath *indexPath = [self.tableView indexPathFor

我的XCode(IOS)中有一个表视图,它将数据传递给我的第二个表视图

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:这就是我所拥有的

@property (nonatomic,weak) NSDictionary *cat;
SecondTableViewController.m

for (NSDictionary *clickresult in cat) {
    NSString *title_cat = [clickresult objectForKey:@"name"];
    NSLog(@"%@", title_cat);
}
在运行代码时,我遇到以下错误:

WebService[7153:90b]0 WebService[7153:90b]-[\uu NSCFConstantString objectForKey::发送到实例0x9ae0的选择器无法识别 WebService[7153:90b]***由于未捕获异常而终止应用程序 “NSInvalidArgumentException”,原因:'-[\uu NSCFConstantString objectForKey::无法识别的选择器已发送到实例0x9ae0'

这是我在运行代码时在调试器左侧看到的内容

cat = (_NSDictionaryl *) class name = _NSDictionaryl 
 -> [0] = @"name" : @"This is my first title"
 -> [1] = @"icon" : @"icon.png"
我需要做什么才能将元素的名称和图标值传递给第二个表视图控制器(cat)

任何帮助都将不胜感激


谢谢

好的。有你的问题。您正在使用弱属性

@property (nonatomic,weak) NSDictionary *cat;
对于您的变量
cat
。它将在初始化后立即释放。尝试对其使用
strong

@property (nonatomic,strong) NSDictionary *cat;

希望这能解决问题

这就是我解决问题的方式

NSString *myTitle = [cat objectForKey:@"name"];
NSString *myIcon = [cat objectForKey:@"icon"];

如果不知道什么是
cat
,就无法具体说明失败的原因。(请注意,调试器显示不可靠--您必须在控制台中使用NSLog或do
po cat
。@hostedvn如果答案解决了您的问题,请接受我这是重复的吗?你们这些家伙更担心这个,而不是试图帮助回答问题。悲伤:S