gpt4 book ai didi

iOS performSelector onThread 与对象

转载 作者:行者123 更新时间:2023-11-28 18:24:45 28 4
gpt4 key购买 nike

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

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

最佳答案

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

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

关于iOS performSelector onThread 与对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12483214/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com