I’m having trouble trying to load objects from an NSDictionary to an NSMutableDictionary – code is as follows :
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
The NSLog command outputs the data in a dictionary style format so I know the data is there, but the addEntriesFromDictionary command fails with the error :
'NSInvalidArgumentException' [NSMutableDictionary addEntriesFromDictionary:]: dictionary argument is not an NSDictionary'.
I’ve tried typecasting the tempDataset but made no difference. Any ideas?
I’m using Xcode 4.3.2, targeting iOS SDK 5.1, ARC enabled.
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;
}
)
);
}
It seems that
tempDatasetis anNSArrayclass.