Search code examples
iphoneobjective-cselectorunrecognized-selectorsudzc

unrecognized selector exception when handling sudzc.com soap result


I have build an app around the sudzc.com generated code to access my soap web service. The soap request and the handling are placed in my UITableViewController subclass.

This is the relevant code:

 1 - (void)viewDidLoad {
 2 [...]
 3 NSLog(@"Starting Soap Request");
 4 CCExample_ManagerService* soapService = [[CCExample_ManagerService alloc] init];
 5 [soapService getActiveVehicles:self action:@selector(getActiveVehiclesHandler:)];
 6 }
 7
 8 - (void) getActiveVehiclesHandler: (id) value {
 9 [...]
10 }

I'm getting the following exception at line 5:

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

After a lot of searching, I am really desperate, since the selector method is in the same class and thus visible. The very same code is also perfectly working in another project, so I'm unsure what prevents it from running in this particular case.


Solution

  • Somewhere you are creating an NSArray and then later trying to add an object to it. NSArray is immutable and doesn't respond to -addObject:. So look for where you are creating or getting an NSArray - probably somewhere in getActiveVehiclesHandler: - and make it an NSMutableArray instead.