Я пытаюсь добавить NSDictionary, содержащий серию ключей, к существующему NSMutableArray с приведенным ниже кодом.Однако после запуска приложения я получаю сбой в самой последней строке ( [self.filtered addObject: nodeData]; ), который говорит: «EXC_BAD_ACCESS», и я не уверен, почему?
ViewController.h
@property (nonatomic, strong) NSMutableArray *filtered;
ViewController.m
-(void)viewDidLoad {
NSString *targetedUser = [self.messageDataFriends objectForKey:@"uid"];
NSString *universal = @"9506";
NSString *myID = [session user][@"user"][@"uid"];
NSPredicate *p1 = [NSPredicate predicateWithFormat:@"uid ==[cd] %@", targetedUser];
NSPredicate *p2 = [NSPredicate predicateWithFormat:@"targetuser ==[cd] %@", myID];
NSPredicate *p3 = [NSPredicate predicateWithFormat:@"uid ==[cd] %@", myID];
NSPredicate *p4 = [NSPredicate predicateWithFormat:@"targetuser ==[cd] %@", targetedUser];
NSPredicate *p5 = [NSPredicate predicateWithFormat:@"targetuser ==[cd] %@", universal];
NSCompoundPredicate *pIntermediary1 = [NSCompoundPredicate andPredicateWithSubpredicates:@[p1, p2]];
NSCompoundPredicate * pIntermediary2 = [NSCompoundPredicate andPredicateWithSubpredicates:@[p3, p4]];
NSCompoundPredicate * pIntermediary3 = [NSCompoundPredicate andPredicateWithSubpredicates:@[p1, p5]];
NSCompoundPredicate *pFinal = [NSCompoundPredicate orPredicateWithSubpredicates:@[pIntermediary1, pIntermediary2, pIntermediary3]];
_filtered = [self.messages filteredArrayUsingPredicate:pFinal];
}
- (IBAction)sendReply:(id)sender {
NSMutableDictionary *nodeData = [NSMutableDictionary new];
[nodeData setObject:@"messages" forKey:@"type"];
NSDictionary *messageValues = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:sentText, nil] forKeys:[NSArray arrayWithObjects:@"value", nil]];
NSDictionary *finalMessage = [NSDictionary dictionaryWithObject:[NSArray arrayWithObject:messageValues] forKey:@"und"];
[nodeData setObject:finalMessage forKey:@"body"];
self.replyField.text = @"";
NSString *targetedUser = [self.messageData objectForKey:@"uid"];
NSDictionary *targetMessage = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:targetedUser, nil] forKeys:[NSArray arrayWithObjects:@"value", nil]];
NSDictionary *finalUser = [NSDictionary dictionaryWithObject:[NSArray arrayWithObject:targetMessage] forKey:@"und"];
[nodeData setObject:finalUser forKey:@"field_targetuser"];
[nodeData setValue: @"Re:" forKey:@"title"];
[self.filtered addObject:nodeData];
NSLog(@"SHOW UPDATED FILTERED %@", self.filtered);
}