我从文本字段中获取姓名和电话号码,直到这里一切正常。当我试图将这些数据添加到我NSMutableDictionary
没有任何反应时。
视图控制器.h
@property(strong,nonatomic) NSMutableDictionary *contacts;
视图控制器.m
- (IBAction)btnAdd:(id)sender {
self.userName = self.name.text;
self.userPhoneNumber = self.phoneNumber.text;
[self addToDictionary:self.userName :self.userPhoneNumber];
NSLog(@"ADDED: Key = %@, Value = %@", self.userName, self.userPhoneNumber);
[self clearTextFields];
}
- (void)addToDictionary: (NSString*) _name: (NSString*) _phone{
[self.contacts setObject:_name forKey:_phone];
}
错误信息
'_name' 的本地声明隐藏了实例变量