Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

To create an empty dictionary, [NSMutableDictionary dictionary] or [[NSMutableDictionary alloc] init]?

To create an empty dictionary, should I call [NSMutableDictionary dictionary] or [[NSMutableDictionary alloc] init]?

What's the difference?

like image 767
Stephen Hsu Avatar asked Nov 11 '10 07:11

Stephen Hsu


People also ask

What is NSMutableDictionary in Swift?

The NSMutableDictionary class declares the programmatic interface to objects that manage mutable associations of keys and values. It adds modification operations to the basic operations it inherits from NSDictionary . NSMutableDictionary is “toll-free bridged” with its Core Foundation counterpart, CFMutableDictionary .

What is NSDictionary in Swift?

In Swift, the NSDictionary class conforms to the DictionaryLiteralConvertible protocol, which allows it to be initialized with dictionary literals. For more information about object literals in Swift, see Literal Expression in The Swift Programming Language (Swift 4.1).


1 Answers

[NSMutableDictionary dictionary] is the same as [[[NSMutableDictionary alloc] init] autorelease]

like image 153
Tyler Bindon Avatar answered Oct 21 '22 18:10

Tyler Bindon