当我尝试向我的可变数组中添加一个对象时,我不断得到一个无法识别的选择器,当我在我的表格 View 中选择一个单元格时,我试图向可变数组中添加和删除项目,这是我的代码:
@interface SomeViewController
@property (nonatomic, strong) NSMutableArray *selectedItems;
@end
查看加载:
-(void)viewDidLoad {
[super viewDidLoad];
self.selectedItems = [[NSMutableArray alloc] init];
}
选择单元格:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
[self.selectedItems addObject:[NSString stringWithFormat:@"%@", cell.contactID]];
MyCell 文件中的 Contact Id 属性是:
@property (strong, nonatomic) NSString *contactID;
我一直收到这个错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM _fastCStringContents:]: unrecognized selector sent to instance 0x7fc3dd1091b0'
最佳答案
某处你有一个你认为是字符串的对象,而实际上它是一个可变数组 - 这就是错误消息所说的。在异常上设置一个断点,它应该告诉你它发生的确切位置,然后找到你认为是字符串的数组。
关于ios - '-[__NSArrayM _fastCStringContents :]: unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37742753/