__NSDictionaryI setObject:forKey:崩溃

时间:2016-07-08 12:39:51

标签: ios objective-c crash nsdictionary nsmutabledictionary

问题是我正在改变NSDictionary,但即使在获得mutableCopy后,该应用也会崩溃。

以下是方法,用于复制:

+ (NSMutableDictionary *)updateQuery:(NSMutableDictionary *)currentQuery toSearchAfterAccountPaginationSequence:(NSString *)accountPaginationSequence {

    //try1
    NSMutableDictionary *mutableQuery = [currentQuery mutableCopy];

    //try2 
    NSMutableDictionary *mutableQuery2=[NSMutableDictionary dictionaryWithDictionary:currentQuery];

    //crashes on this line
    mutableQuery[@"where"][@"account_pagination_sequence"] = @{ @"lt" : accountPaginationSequence };

    return mutableQuery;
}

错误日志(应用程序在有限数量的设备上崩溃)

[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance

1 个答案:

答案 0 :(得分:2)

我认为这是你想要实现的目标

for(int i = 0; i< n; i++){
   cin >> a[i];
}

编辑: 在Objective-C中调用对象上的mutableCopy不是递归的。你也需要在嵌套对象中调用mutableCopy。