【发布时间】:2014-05-07 21:30:40
【问题描述】:
我的代码给出了一个错误提示
“NSMutableDictionary”没有可见接口声明选择器“addObjects:forKey:”
.h
@interface ViewController : UIViewController{
NSMutableDictionary *credtialsDictionary;
}
-(IBAction)registerlogin;
@end
.m
@implementation ViewController
-(IBAction)registerlogin{
[credtialsDictionary addObjects:passwordFieldregister.text forKey:usernameFieldregister];
}
@end
我不明白为什么这个IBAction 不允许我向NSMutableDictionary 添加对象
【问题讨论】:
-
你检查过 NSMutableArray 的规范,看看是否定义了
addObjects:forKey:??? -
@HotLicks,尽管它会做的所有好事,看到 OP 正试图将对象添加到字典中......
-
你为什么要调用一个名为
addObject的方法s:却只传递一个对象? -
@Jonathan。 ——哎呀!! ;)
-
用户,两个非常关键的编程技能是学习查找和使用参考文档以及学习实际阅读错误消息(而不仅仅是将它们解释为“哦,有东西神秘错误”)。你基本上在这两个方面都没有通过这个测试。下次请努力做得更好。
标签: ios objective-c cocoa-touch compiler-errors nsmutabledictionary