gpt4 book ai didi

ios - __NSDictionaryI setObject :forKey: Crash

转载 作者:行者123 更新时间:2023-11-28 21:25:34 27 4
gpt4 key购买 nike

问题是我正在改变 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

最佳答案

我想这就是你想要达到的目标

+ (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;
}

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

关于ios - __NSDictionaryI setObject :forKey: Crash,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38266941/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com