iOS performSelector onThread with object

时间:2012-09-18 18:54:31

标签: ios performselector

是否可以使用此方法并传递对象?使用此代码,我收到此错误:

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

它永远不会到达hideUpdateView方法......

代码:

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
}

1 个答案:

答案 0 :(得分:6)

您在选择器名称的末尾缺少冒号。 (请阅读Objective-C turorial。冒号是选择器名称的一部分。)

[self performSelector:@selector(hideUpdateView:) onThread:[NSThread mainThread] withObject:array waitUntilDone:YES];
                                              ^
                                     Note the colon here