Objective-C - Adding items from NSDictionary to NSMutableDictionary

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;
            }
        )
    );
}

Answers


It seems that tempDataset is an NSArray class.


Flink's answer that it is an NSArray class should be correct. Also, if you really do need to convert an NSDictionary to an NSMutableDictionary, its far easier to use myDictionary.mutableCopy.


Need Your Help

Controlling Task execution order with ExecutorService

java concurrency executorservice

I have a process which delegates asynch tasks to a pool of threads. I need to ensure that certain tasks are executed in order.

Get Current or Next Sibling Element Matching Selector

jquery jquery-selectors

I recently posted the question Get Next Element that is Visible and Does Not Have Attribute, in which I asked how to get the next sibling that is both visible and does not have the attribute