Initializing an NSDictionary

tryKuldeepTanwar

Is there any difference between initializing an NSDictionary by this way:

self.myData = [[NSDictionary alloc] init];
[self.myData initWithObjects:objects forKeys:keys];

or this way:

self.myData = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];

Because the reason I'm asking this question is the first one is not working. I'm new and curious to know why?

Here's My Code :-

enter image description here

gnasher729

The first version calls init twice, which is a very, very bad thing to do in most cases, but especially bad for built-in classes like NSDictionary. I have never tried this, but it should crash because you initialised an immutable dictionary, and the second attempt to initialise would modify it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Troubles initializing NSDictionary in Swift

From Dev

[NSDictionary]!? is not convertible to [NSDictionary]?

From Dev

Sort NSDictionary

From Dev

NSDictionary to NSMutableArray

From Dev

NSDictionary to NSData and NSData to NSDictionary in Swift

From Dev

Initializing a reference

From Dev

Initializing QGenericMatrix

From Dev

UITableview with NSArray contains NSDictionary and NSDictionary containg another NSDictionary

From Dev

Extracting an NSDictionary from within another NSDictionary

From Dev

Extracting an NSDictionary from within another NSDictionary

From Dev

Use NSDictionary as other NSDictionary's key

From Dev

Appending NSDictionary to [NSDictionary] gives unexpected results

From Dev

search element in NSDictionary nested in another NSDictionary

From Dev

Difference between initializing in initialization list and initializing in the constructor

From Dev

Casting NSDictionary as Dictionary Swift

From Dev

convert NSObject to NSDictionary

From Dev

Detect a Null value in NSDictionary

From Dev

How to convert NSManagedObject to NSDictionary

From Dev

Convert output of mdls to NSDictionary

From Dev

Creating a Model Object with an NSDictionary

From Dev

Retrieving keys from NSDictionary

From Dev

Converting NSObject to NSDictionary

From Java

Converting NSString to NSDictionary / JSON

From Dev

NSDictionary order of keys and values

From Dev

Updating NSDictionary inside an NSArray

From Dev

Convert a JSON NSData to NSDictionary

From Dev

Convert Swift Dictionary to NSDictionary

From Dev

Parse XML to NSDictionary

From Dev

Convert NSDictionary to NSMutableArray