NSDictionary
To declare and instantiate an NSDictionary
with a known set of keys and values previously, a class method or equivalent alloc
/init
needed to be used:
NSDictionary *workDict =[NSDictionarydictionaryWithObjectsAndKeys:@"float",floatNumber, @"integer", integerNumber, @"array",workArray, nil];
With the new syntax, declaring and instantiating an NSDictionary
is much simpler, much less verbose, and easier to read:
NSDictionary *workDict = @{ @"float": floatNumber, @"integer" : integerNumber, @"array" : workArray };
Be sure to note, however, that putting a nil
object as either a key or a value either will cause a warning if the compiler ...
Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.