5

I have

NSMutableDictionary *myDictionary = [[NSMutableDictionary alloc] init];
id dict = [myDictionary copy];

but is dict now just a regular NSDictionary? Or is it a copy of the NSMutableDictionary?

Also, is there any way to go from mutable to non-mutable?

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284

1 Answers1

18

There are two methods involved here; -copy and -mutableCopy.

If the class holds a distinction; -copy always creates an immutable copy; and -mutableCopy always creates a mutable copy.

If the class holds no distinction; -copy always creates a true copy.

So yes, dict is now an NSDictionary, containing the objects in the dictionary.

Williham Totland
  • 28,471
  • 6
  • 52
  • 68