Ios 发送到实例的选择器无法识别

Ios 发送到实例的选择器无法识别,ios,cocoa-touch,Ios,Cocoa Touch,我正在使用主详细信息模板。 头文件MasterViewController.h: #import <UIKit/UIKit.h> //(Imported both MasterViewController.h and DetailViewController.h in implementation file of MasterViewController.m) @class DetailViewController; @interface MasterViewController

我正在使用主详细信息模板。

头文件MasterViewController.h:

#import <UIKit/UIKit.h>
//(Imported both MasterViewController.h and DetailViewController.h in implementation file of MasterViewController.m)
@class DetailViewController;

@interface MasterViewController : UITableViewController

@property (strong, nonatomic) DetailViewController *detailViewController;
-(void)createFlowerData;
@end
然后,当我在ios模拟器(iPad)上构建应用程序时,我得到以下信息:

(请注意,我没有包括所有内容,只是我认为重要的部分)


这一整天都让我发疯,我检查了好几次,重写了整件事,结果还是一样,我甚至不能让细胞显示出来。我在谷歌上搜索了一下,我发现这意味着我正在向一个不知道该怎么处理的方法发送一条消息,但我确信这是对的?有人能帮我调试一下吗

如果您不使用ARC:您需要保留您的每一本词典。像这样
redFlowers=[[NSMutableArray alloc]init]retain]为每个阵列执行此操作。另外,
NSLog(@“%@”,redFlowers)
位于应用程序崩溃的代码行之前,并发布输出。将redFlowers替换为下一个要调用的字典。

从我得到的信息来看,您需要做的是首先创建NSDictionary对象,然后将这些对象添加到NSMutableArray

     NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
     [dic setValue:@"Poppy" forKey:@"name"];
     [dic setValue:@"Poppy.png" forKey:@"picture"];
     [dic setValue:@"http://en.wikiepdia.org/wiki/Poppy" forKey:@"url"];

     [redFlowers addObject:dic];
     [dic release];     // Dont use this in case of ARC
对所有三个或多个需要添加的对象重复此操作。希望这有帮助

cell.imageView.image = _flowerData[indexPath.section][indexPath.row][@"picture"];
此行
cell.imageView.image
expect
UIImage
type

[redFlowers addObject:@{@"name":@"Gerbera",@"picture":@"Gerbera.png",@"url":@"http://en.wikiepdia.org/wiki/Gerbera"}];
但是您在这里给它一个
NSString
,这会导致运行时错误

所以应该是这样

cell.imageView.image = [UIImage imageNamed:_flowerData[indexPath.section][indexPath.row][@"picture"]];

您应该添加一个异常断点来精确定位麻烦的行。@rdelmar更好的解决方案是只在几个地方记录NSLog。省去了每次重新编译以找到它的麻烦,还可以跟踪在应该释放之前释放的变量。@IsaiahTurner实际上NSLog在这种情况下没有任何帮助。使用NSLog进行调试并不是很好的调试方法。断点可用于记录日志,甚至无需重新启动应用程序。1。这并没有解决问题。2.您假设代码不使用ARC,我认为这是错误的。@xlc对不起,所以习惯了不使用ARC。更正的答案。还有一件事,您不需要保留
alloc
ed对象。否则您需要释放两次。@isiahturner 1。它应该是
NSMutableDictionary
。2.原始代码的可读性和简单性更好。3.这并没有解决问题。
[redFlowers addObject:@{@"name":@"Gerbera",@"picture":@"Gerbera.png",@"url":@"http://en.wikiepdia.org/wiki/Gerbera"}];
cell.imageView.image = [UIImage imageNamed:_flowerData[indexPath.section][indexPath.row][@"picture"]];