Actually, they are different, but not for the reason you expect. I'm going to assume you're using ARC (and if you're not, why not?), so the auto-releasedness of the returned object doesn't matter.
Here's how they differ: consider what happens if otherDictionary
is nil
.
Well, if you use:
[otherDictionary copy]; // or -mutableCopy
You'll get back nil
, because you have a nil
receiver.
On the other hand, if you use:
[NS(Mutable)Dictionary dictionaryWithDictionary:otherDictionary];
You will get back an NS(Mutable)Dictionary
, regardless of whether otherDictionary
is nil
or not.
This is nice in the situation where you need to create a copy of a dictionary and want an NSDictionary
instance afterwards, but you don't want to test for nil
(yay for reducing cyclomatic complexity!).