[英]__NSDictionaryI setObject:forKey: Crash
The problem is that I am mutating a NSDictionary
, but even after getting a mutableCopy
, the app crashes. 问题是我正在更改NSDictionary
,但是即使获取了mutableCopy
,应用程序也会崩溃。
Below is Method for copy : 以下是复制方法 :
+ (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;
}
Error Log (the app crashes on a limited amount of devices) 错误日志(应用在数量有限的设备上崩溃)
[__NSDictionaryI setObject:forKey:]: unrecognized selector sent to instance
i think this is what you trying to achieve 我认为这是您想要实现的目标
+ (NSMutableDictionary *)updateQuery:(NSMutableDictionary *)currentQuery toSearchAfterAccountPaginationSequence:(NSString *)accountPaginationSequence {
//try1
NSMutableDictionary *mutableQuery = currentQuery.mutableCopy;
NSMutableDictionary *where = mutableQuery[@"where"].mutableCopy;
where[@"account_pagination_sequence"] = @{ @"lt" : accountPaginationSequence };
mutableQuery[@"where"] = where;
return mutableQuery;
}
Edit: In Objective-C calling mutableCopy on objects is not recursive.You need to call mutableCopy in nested objects too. 编辑:在Objective-C中,对对象调用mutableCopy不是递归的。您也需要在嵌套对象中调用mutableCopy。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.