gpt4 book ai didi

ios - 具有多个参数错误的 performSelector afterDelay

转载 作者:行者123 更新时间:2023-11-29 13:30:35 28 4
gpt4 key购买 nike

我在这段代码中使用 performSelector 方法时遇到了一些问题:

这个方法在另一个名为“JSONMethods”的类中:

+(void)sendPostMsgWithMultipleArguments:(NSArray *)myArgs {
[self sendPostMsg:[myArgs objectAtIndex:0]:[myArgs objectAtIndex:1]];
}

然后,在另一个类上我接到了电话:

- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Loading...";

JSONMethods *methods = [[JSONMethods alloc]init];
NSArray *arguments = [[NSMutableArray alloc]initWithObjects:@"http://localhost/promos/txFirmas.php",[NSString stringWithFormat:@"sensor=%d",tableViewNumber], nil];
[methods performSelector:@selector(sendPostMsgWithMultipleArguments:)
withObject:arguments
afterDelay:3.0];

NSString *tit = [NSString stringWithFormat:@"Sign: %d",tableViewNumber];
self.title = tit;
}

我想等到“sendPostMsgWithMultipleArguments:”完成更改标题,我该怎么做?当我对此进行测试时,我的应用程序崩溃并通过控制台向我显示:

2012-08-17 12:09:15.966 MapaProject[524:11603] -[JSONMethods sendPostMsgWithMultipleArguments:]: unrecognized selector sent to instance 0x7c85b70
2012-08-17 12:09:15.968 MapaProject[524:11603] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JSONMethods sendPostMsgWithMultipleArguments:]: unrecognized selector sent to instance 0x7c85b70'
*** First throw call stack:
(0x133a022 0x2016cd6 0x133bcbd 0x12a0ed0 0x12a0cb2 0xa1c85d 0x130e936 0x130e3d7 0x1271790 0x1270d84 0x1270c9b 0x15db7d8 0x15db88a 0xf6626 0x236d 0x20c5)
terminate called throwing an exception

你能帮帮我吗?提前致谢:)

最佳答案

更改 +(void)sendPostMsgWithMultipleArguments:(NSArray *)myArgs

-(void)sendPostMsgWithMultipleArguments:(NSArray *)myArgs

或者更好的改变


[方法 performSelector:@selector(sendPostMsgWithMultipleArguments:) withObject:arguments afterDelay:3.0];

[[方法类] performSelector:@selector(sendPostMsgWithMultipleArguments:)
withObject:参数
afterDelay:3.0];

关于ios - 具有多个参数错误的 performSelector afterDelay,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12004154/

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