我在尝试将对象从 an 加载NSDictionary
到 an 时遇到问题NSMutableDictionary
- 代码如下:
dictListData = [[NSMutableDictionary alloc] initWithCapacity:200];
...
NSError *jsonError = nil;
NSDictionary *jsonResultDict = [NSJSONSerialization JSONObjectWithData:[httpRequestCopy responseData] options:kNilOptions error:&jsonError];
NSDictionary *tempDataset = [[jsonResultDict objectForKey:@"result"] objectAtIndex:0];
NSLog(@"tempDataset = %@", tempDataset);
[dictListData addEntriesFromDictionary:tempDataset]; // <-- Error here
该NSLog
命令以字典样式格式输出数据,因此我知道数据在那里,但是 addEntriesFromDictionary 命令失败并出现错误:
'NSInvalidArgumentException' [NSMutableDictionary addEntriesFromDictionary:]: dictionary argument is not an NSDictionary'.
我尝试过对 tempDataset 进行类型转换,但没有任何区别。有任何想法吗?
我正在使用 Xcode 4.3.2,针对 iOS SDK 5.1,启用了 ARC。
jsonResultDict = {
result = (
(
{
stCode = 000477065;
stDesc1 = "TIMER KNOB";
stQtyFree = 0;
stQtyInStock = 0;
},
{
stCode = 0010311;
stDesc1 = "DBLE TAPER CHUCK CAP";
stQtyFree = 10;
stQtyInStock = 10;
},
{
stCode = "0016-103";
stDesc1 = "1/8 I.D";
stQtyFree = 0;
stQtyInStock = 0;
},
{
stCode = "0016-104";
stDesc1 = "1/4 I.D";
stQtyFree = 0;
stQtyInStock = 0;
},
{
stCode = "0016-157";
stDesc1 = "1/8 x 1/16 X 1/8 TEE";
stQtyFree = 0;
stQtyInStock = 0;
}
)
);
}