I got a really weird bug in my app today:
NSMutableDictionary *testLocal = [[NSMutableDictionary alloc] init];
[testLocal setObject:@"Test" forKey:@"title"];
[testLocal setObject:@"test notification" forKey:@"body"];
[testLocal setObject:@"1" forKey:@"repeat"];
[testLocal setObject:@"26.04.2011 - 12:53" forKey:@"start"];
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithDictionary:[saver read]];
[[dict objectForKey:@"content"] addObject:testLocal]; //Crashes here! (SIGABRT)
The method [saver read] returns this:
{
content = (
{
body = "test notification";
repeat = 1;
start = "26.04.2011 - 13.06";
title = Test;
}
);
}
So I don’t see the error because the dict I write to is mutable and the key “content” is an array.
Thanks in advance.
mavrick3.
[saver read]:
- (NSDictionary *)read {
return [[NSDictionary alloc] initWithContentsOfFile:[self filePath]];
}
Try checking out what class the object returned by
[dict objectForKey:@"content"]is. Then things will be much clearer to you. I suspect it is not returning anNSMutableArrayinstance but something else, most likelyNSArraywhich doesn’t respond to methodaddObject: