ios - '-[__NSArrayM _fastCStringContents :]: unrecognized selector sent to instance

标签 ios objective-c uitableview nsstring nsarray

当我尝试向我的可变数组中添加一个对象时,我不断得到一个无法识别的选择器,当我在我的表格 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/

相关文章:

ios - Xcode 显示加载 View ,直到加载第二个 View (在 segue show 上)

ios - UITableView 自定义单元格 IBOutlets 为零

ios - 在表格 View 单元格中显示事件指示器

ios - 如何更改 UISearchBar 中 UITextField 的属性

c++ - Apple C 模块进入 Xcode 工具链是否有时间表?

ios - 更改 UIViewController 的方向会影响另一个 UITableViewController 的边界

ios - 使用CAShapeLayer的HitTest无法正常工作

ios - 如何在swift中禁用导航 Controller 向右滑动

ios - 验证错误 : Invalid Bundle. ... 中的包包含不允许的文件 'Frameworks'

iphone - 用于反转TitleShadowWhenHighlighted 选定状态的UIButton 模拟