Reputation: 711
main_dict = [[NSDictionary alloc] init];
NSMutableArray *insert = [[NSMutableArray alloc] init];
[insert addObject:main_event];
NSString *count = [NSString stringWithFormat:@"%i",total_count];
[main_dict setValue:insert forKey:count];
I initialized the NSDictionary, main_dict and the NSMustableArray, insert. Then I added the main_event to the insert array. Finally added that array into dictionary with the key value.
I got SIG_ABRT signal when I stepped into the [main_dict setValue:insert forKey:count];
What's wrong? I have all the elements initialized and have values, but still SIG_ABRT.
Upvotes: 1
Views: 133
Reputation:
You need to change the data type of main_dict
to mutable type. NSDictionary
is an immutable type and you can not edit it. So change it as main_dict = [[NSMutableDictionary alloc] init];
Upvotes: 4
Reputation: 35181
You cannot modify NSDictionary type instance. Just replace
main_dict = [[NSDictionary alloc] init];
to
main_dict = [[NSMutableDictionary alloc] init];
will solve this issue.
Upvotes: 2