I am trying to delete object from a NSMutableArray
but still getting the above mentioned error.Here is how I am creating and using the array.
#import "CartViewController.h"
@interface CartViewController ()
{
NSMutableArray *orderDetails; //my Array
}
@end
-(void)getCart{
SuccessBlock successBlock = ^(NSData *response){
NSDictionary *responseDict = [NSJSONSerialization JSONObjectWithData:response options:NSJSONReadingMutableContainers error:nil];
orderDetails = [[NSMutableArray alloc]init];
orderDetails = [responseDict objectForKey:@"orderDetails"];
[self.cartTableView reloadData];
};
FailureBlock failureBlock = ^(NSError *error){
NSLog(@"Failure Block %@",[error localizedDescription]);
};
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@00",BASE_URL,GET_CART]];
HTTPPostRequest *postReq = [[HTTPPostRequest alloc]initWithURL:url successBlock:successBlock failureBlock:failureBlock];
[postReq startRequest];
}
Now I am using SWTableViewCell from which I want to delete a particular cell, and hence a entry from array.
#pragma mark - SWTableViewDelegate
- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerLeftUtilityButtonWithIndex:(NSInteger)index
{
switch (index) {
case 0:
{
NSLog(@"left button 0 was pressed");
[cell setLeftUtilityButtons:[self leftUndoButton]WithButtonWidth:self.cartTableView.frame.size.width];
[cell showLeftUtilityButtonsAnimated:YES];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
[self deleteCell:cell];
});
break;
}
default:
{
break;
}
}
}
-(void)deleteCell:(SWTableViewCell *)cell{
NSIndexPath *cellIndexPath = [self.cartTableView indexPathForCell:cell];
[orderDetails[cellIndexPath.section] removeObjectAtIndex:cellIndexPath.row];//Exception breakpoint stops here by showing : [__NSDictionaryM removeObjectAtIndex:]: unrecognized selector sent to instance 0x7968afd0
[self.cartTableView deleteRowsAtIndexPaths:@[cellIndexPath] withRowAnimation:UITableViewRowAnimationLeft];
}