gpt4 book ai didi

ios - replaceObjectAtIndex objectforKey 崩溃

转载 作者:行者123 更新时间:2023-11-28 20:04:41 28 4
gpt4 key购买 nike

我想用其他值替换数组的内容,

这是我的数组值:

    [Arr objectAtIndex:i] =  "End_Date" = "31 Mar 2014";
"Merchant_Category_Id" = 162;
"Merchant_ID" = 1262;
"Merchant_Name" = Mp;
"Merchant_SmallImage" = "http://abcdm/imge/cb256.jpg";
"Voucher_Id" = 130510;
"Voucher_Name" = "Rs 555 OFF";
favStatus = 0;

我想做的是,我想将索引 i 处的 favStatus 从 0 更新为 1

这是我试过的代码片段,

[Arr replaceObjectAtIndex:[[[Arr objectAtIndex:i] objectForKey:@"favStatus"] integerValue] withObject:@"1"];

每次它返回值 0 当我记录 [[[Arr objectAtIndex:i] objectForKey:@"favStatus"] integerValue]

请帮助并提前致谢。

最佳答案

您正在用字符串 @"0"替换整个对象(字典)。

事实上你可以创建一个新的tempDictionary,并提取@"favStatus"的keyValue。替换它,然后将新对象放入数组中:

NSMutableDictionary *tempDictionary = [[Arr objectAtIndex:i] mutableCopy];
[tempDictionary setValue:@"0" forKey:@"favStatus"];

[Arr replaceObjectAtIndex: i
withObject: tempDictionary];

关于ios - replaceObjectAtIndex objectforKey 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22472608/

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