gpt4 book ai didi

ios - 无法在 performSelectorInBackground 中调用实例方法

转载 作者:行者123 更新时间:2023-11-28 20:04:33 26 4
gpt4 key购买 nike

我有一个类 MatchDayDataController ,有一个方法 pushIncompleteDataToServer。

在另一个类 SummaryVC.m 中,我想在 performSelectorInBackground 中调用 pushIncompleteDataToServer。

代码:

 MatchDayDataController *sharedDataController = [MatchDayDataController sharedDataController];
[self performSelectorInBackground:@selector([sharedDataController pushIncompleteDataToServer]) withObject:nil];

它显示了 performSelectorInBackground 中的一些语法错误。我在这里错过了什么?请指导。

最佳答案

[self performSelectorInBackground:@selector([sharedDataController pushIncompleteDataToServer]) withObject:nil];

这将使代码在同一个类中搜索方法

应该是:

[sharedDataController performSelectorInBackground:@selector(pushIncompleteDataToServer) withObject:nil];

这将调用 sharedDataController 类中的方法

此外,在方法 performSelectorInBackground: withObject: 中,withObject 用于将参数传递给选择器方法。在这种情况下,由于没有参数,我们传递 nil。

关于ios - 无法在 performSelectorInBackground 中调用实例方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22524002/

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