I get some data from the server and save it to NSDictionary
then I want to initialise NSMutableDictionary
with that NSDictionary
.
NSDictionary * const received = [self serverData];
NSMutableDictionary * const results = [NSMutableDictionary dictionaryWithDictionary:received];
And If I get empty JSON from the server and consequently my NSDictionary
will be empty how can I use dictionaryWithDictionary
for an empty one? I use this
NSDictionary * const received = [self serverData];
NSMutableDictionary * const results;
if (![received count]) {
results = [NSMutableDictionary dictionary];
}
else
{
results = [NSMutableDictionary dictionaryWithDictionary:received];
}
But it seems a code smell. May be there are more elegant solutions?