views:

60

answers:

1

Hello i am having problem in copying data from one NSDictionary to another i used the

[dicForFoodproduct_fromWeb initWithDictionary:dictforfoodproduct];

Here it terminates and says "unrecognized selecter sent to the instance..." I am getting 5 key values in dictForFoodProduct but am unable to copy that key values into dicForFoodProduct_fromWeb.

+2  A: 
NSDictionary *newDictionary = [[NSDictionary alloc] initWithDictionary:otherDictionary];
Nick
mrugen: Don't ever send an `init` or `initWithWhatever:` message to an already-initialized instance. It always causes other problems—maybe obvious, maybe subtle, but always serious enough that you should never do this. You should only ever initialize an uninitialized instance—i.e., one just returned by `alloc` or `allocWithZone:`.
Peter Hosey
ya thansk for your inputs ,will take care of that
mrugen
Yes sorry for the lack of additional context in my original answer. Peter's comments are words to live/code by. If you have a mutable dictionary there are other methods to replace contents with another dictionary.
Nick