【发布时间】:2015-03-03 09:19:26
【问题描述】:
尝试将名为 object 的 NSString 对象添加到我的数组时出现此错误:
erminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance 0x7fc48ae52ba0'
不知道为什么会这样。我最初使用 NSArray 将其更改为 NSMutableArray 但我仍然遇到问题。代码如下:
-(NSMutableArray *)getReplyArrayForMessage: (NSString *)message {
//get the array
NSMutableArray *replies = [self.messageDictionary objectForKey:message];
NSLog(@"%@",replies);
//if no replies we init the base set
if([replies count]==0) {
//get the base array
//this also works if a key just isn't in the dictonary
return replies=[self getBaseArray];
}
else {
//add the other message
NSString *object = @"Send a different message";
[replies addObject:object];
return replies;
}
}
如果有人能告诉我为什么会发生这种情况,我将不胜感激。菜鸟在这里。
【问题讨论】:
-
你是如何让它可变的?
标签: ios objective-c nsmutablearray