Kuldeep1007tanwar Kuldeep1007tanwar - 8 months ago 28
iOS Question

Initializing an NSDictionary

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 when I apply it in TableView. I'm new and curious to know why?

Here's My Code :-

enter image description here


on your choice 1 already you initialise the memory of your Dictionary in some where else in your current class, so In here no need of another one time for initialise ,you can set the object directly like

[self.myData setObject:@"Value" forKey:@"your key"];