Question

Is it possible to use this method and pass an object? With this code, I get this error:

-[myApp hideUpdateView]: unrecognized selector sent to instance 0x8b6a880
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[myApp hideUpdateView]: unrecognized selector sent to instance 0x8b6a880'

It never reaches the hideUpdateView method...

Code:

NSArray *array = [NSArray arrayWithObjects:@"1", @"2", nil];
[self performSelector:@selector(hideUpdateView) onThread:[NSThread mainThread] withObject:array waitUntilDone:YES];



- (void) hideUpdateView: (NSArray *) inputArray
{
    int catCount = [[inputArray objectAtIndex:0] intValue];
    //hide it
}
Was it helpful?

Solution

You're missing the colon from the end of the selector name. (Please, read an Objective-C turorial. The colon is part of the name of the selector.)

[self performSelector:@selector(hideUpdateView:) onThread:[NSThread mainThread] withObject:array waitUntilDone:YES];
                                              ^
                                     Note the colon here
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top