Я реализовал этот код, когда я пытаюсь добавить объекты, он работает нормально, но когда я пытаюсь удалить объект, он дает мне exc_bad_access, я пытаюсь выяснить это путем установки точек останова, но все же я не могу понять причину этого.Пожалуйста, помогите мне.
в файле .h
BOOL prayValues[1000];
BOOL praiseValues[1000];
IBOutlet UITableView *prayTable;
IBOutlet UITableView *praiseTable;
NSMutableArray *publishingMyPosts;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//NSLog(@"sterrrr----%@",str);
if (tableView == myTableView) {
NSLog(@"did select in tableview");
}
if (jsonRequestChecking==2) {
UITableViewCell *thisCell1 = [prayTable cellForRowAtIndexPath:indexPath];
UITableViewCell *thisCell2 = [praiseTable cellForRowAtIndexPath:indexPath];
if (tableView == prayTable) {
NSLog(@"did select in prayTable");
prayValues[indexPath.row] = !prayValues[indexPath.row];
if (prayValues[indexPath.row]) {
thisCell1.accessoryType = UITableViewCellAccessoryCheckmark;
NSLog(@"this cell1 text %@",thisCell1.textLabel.text);
str=[NSString stringWithFormat:@"%@",[[publicArray objectAtIndex:indexPath.row] objectForKey:@"id"]];
if (([publishingMyPosts containsObject:str] == NO)){
[publishingMyPosts addObject:str];
// NSLog(@"publishing my post %@",publishingMyPosts);
}
} else {
thisCell1.accessoryType = UITableViewCellAccessoryNone;
[publishingMyPosts removeObject:str];
//NSLog(@"publishing my post %@",publishingMyPosts);
}
}
if (tableView == praiseTable) {
NSLog(@"did select in praiseTable");
praiseValues[indexPath.row] = !praiseValues[indexPath.row];
if (praiseValues[indexPath.row]) {
str1=[NSString stringWithFormat:@"%@",[[privateArray objectAtIndex:indexPath.row] objectForKey:@"id"]];
thisCell2.accessoryType = UITableViewCellAccessoryCheckmark;
NSLog(@"this cell2 text %@",thisCell2.textLabel.text);
if (([publishingMyPosts containsObject:str1] == NO)){
[publishingMyPosts addObject:str1];
// NSLog(@"publishing my post %@",publishingMyPosts);
}
} else {
thisCell2.accessoryType = UITableViewCellAccessoryNone;
[publishingMyPosts removeObject:str1];
//NSLog(@"publishing my post %@",publishingMyPosts);
}
}
}
NSLog(@"publishing my post %@",publishingMyPosts);
}