0

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

-[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
}
4

1 回答 1

6

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

[self performSelector:@selector(hideUpdateView:) onThread:[NSThread mainThread] withObject:array waitUntilDone:YES];
                                              ^
                                     Note the colon here
于 2012-09-18T18:56:50.993 回答