App crashing when deleting item from NSMutableArray, but only when certain conditions are met

I have an app, written in Objective-C, that needs to display a UITable of numbers. The list of numbers is taken from an NSMutableArray whose information is taken from a .plist file. Normally, all is fine.

However, the app includes settings to organize the numbers in specific ways. The default setting just organizes them in alphabetical order. The next organizes them in reverse to the default. Those two settings are fine. The problem arises when one selects the setting that organizes the table by splitting the odd numbers and the even numbers. This is the code that splits them:

for (int i = 0; i < [tempGeneralSorterArray count]; i++) {     NSString *tempHouseNumber = [[tempGeneralSorterArray objectAtIndex:i] stringByTrimmingCharactersInSet:letters];     int tempHouseNumberValue = [tempHouseNumber intValue];      if (tempHouseNumberValue % 2 == 0) //% is the modulo operator, shows what's left after a division     {         //even         [tempEvenSorterArray addObject:[tempGeneralSorterArray objectAtIndex:i]];         [tempEvenSorterArray sortUsingSelector:@selector(compare:)];     }     else     {         //odd         [tempOddSorterArray addObject:[tempGeneralSorterArray objectAtIndex:i]];         [tempOddSorterArray sortUsingSelector:@selector(compare:)];     } } 

After this, the app combines the two arrays (tempOddSorterArray and tempEvenSorterArray) in different ways depending on the setting chosen, but in general like this:

customerArray = [tempOddSorterArray arrayByAddingObjectsFromArray:tempEvenSorterArray]; 

The table displays mostly fine, but when I try to delete a cell, I get an error. It crashes at this line:

[customerArray removeObjectAtIndex:indexPath.row]; 

I get this in the debugger:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI removeObjectAtIndex:]: unrecognized selector sent to instance 0x7fae62410f30' 

Any help would be appreciated, and I'll gladly give more info or code if needed.

Also, all arrays used here are NSMutableArrays.

Replay

Category: ios Time: 2016-07-31 Views: 6

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.199 (s). 12 q(s)