gpt4 book ai didi

ios - 追加数组 NSDictionary 时出错

转载 作者:行者123 更新时间:2023-11-29 12:52:48 25 4
gpt4 key购买 nike

<分区>

我试图将 JSON 数据放入数组。下面是代码...我不知道我哪里错了..

当我为 arrayJSON 保留日志时,结果如下:

Array Result: [{"ID_PROJECT":1,"NM_PROJECT":"TED"},{"ID_PROJECT":2,"NM_PROJECT":"DL"},{"ID_PROJECT":3,"NM_PROJECT":"PERD"},{"ID_PROJECT":4,"NM_PROJECT":"EPRS "},{"ID_PROJECT":5,"NM_PROJECT":"MSCS"}]

NSArray *arrayJSON = [NSJSONSerialization JSONObjectWithData:urlData
options:NSJSONReadingAllowFragments
error:&error];

NSMutableArray *arrayResult = [NSMutableArray array];

for(NSDictionary *dictJSON in arrayJSON){

[arrayResult addObject: [dictJSON objectForKey:@"NM_PROJECT"]];
}

NSLog(@"Array Result: %@", arrayResult);

这是错误代码:

014-02-25 15:07:40.602 Demologin[1146:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x715f430' * First throw call stack: (0x1ca3012 0x114fe7e 0x1d2e4bd 0x1c92bbc 0x1c9294e 0xad28 0x1061c7 0x106232 0x553d5 0x5576f 0x55905 0x5e917 0x2296c 0x2394b 0x34cb5 0x35beb 0x27698 0x1bfedf9 0x1bfead0 0x1c18bf5 0x1c18962 0x1c49bb6 0x1c48f44 0x1c48e1b 0x2317a 0x24ffc 0x26ad 0x25d5) libc++abi.dylib: terminate called throwing an exception

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