objective c - changing a key name in NSDictionary -


i have method returns me nsdictionary keys , values. need change key names dictionary new key name values need same key,but stuck here.need help

this method work mutable dictionary. doesn't check should done if new key exists.

you can mutable dictionary of immutable calling mutablecopy on it.

- (void)exchangekey:(nsstring *)akey withkey:(nsstring *)anewkey inmutabledictionary:(nsmutabledictionary *)adict {     if (![akey isequaltostring:anewkey]) {         id objecttopreserve = [adict objectforkey:akey];         [adict setobject:objecttopreserve forkey:anewkey];         [adict removeobjectforkey:akey];     } } 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -