Reputation: 4441
How could I generate an NSMutableDictionary
of the following format:
{
sitedetails = {
currency;
ere = {
price = {
test = {
gte = 100;
};
};
};
};
}
sitedetails
is the key and currency (NSString
) and ere
(NSMutableDictionary
with its own objects) are the objects of this NSMutableDictionary
.
NSMutableDictionary *dict1 = ;[NSMutableDictionary alloc] init];
[dict1 setObject:@"currency" forKey:@"sitedetails"];
NSMutableDictionary *dict2 = ;[NSMutableDictionary alloc] init];
[dict2 setObject:ereDict forKey:@"sitedetails"];
[dict1 addEntriesFromDictionary:dict2];
This didn't let me add the string value in for dict1
. Any idea where I'm going wrong?
{
sitedetails = {
ere = {
price = {
test = {
gte = 100;
};
};
};
};
}
Upvotes: 0
Views: 53
Reputation: 2052
because dict1 and dict2 have the key 'sitedetails'. Keys should be unique in a dictionary. From NSMutableDictionary reference manual
If both dictionaries contain the same key, the receiving dictionary’s previous value object for that key is sent a release message, and the new value object takes its place.
Upvotes: 2