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

Chameleon Templating: Default value in 'tal:switch'

python switch-statement template-engine chameleon

I am trying to build a switch/case structure around a range of integer values. As stated in the language reference, if the case expression is the symbol default, it always matches the switch. Howev...

.Net Binary Serialization inheritance

c# inheritance serialization

In a C# Context, I have a Class B which is marked as Serializable and who's inheriting form a Class A who's not marked as this. Can i find a way to serialize instance of B without marking A as