gpt4 book ai didi

iOS Swift 3 performSelector onMainThread

转载 作者:搜寻专家 更新时间:2023-10-31 22:19:17 24 4
gpt4 key购买 nike

我在 Objective-C 中使用了这一行

[self performSelectorOnMainThread: @selector(importComplete)
withObject: nil waitUntilDone: YES];

我试图将上面的行转换为任意数量的变体,但没有找到任何可以编译的东西。我目前的尝试如下:

performSelector (onMainThread: #selector(importComplete), withObject:nil, waitUntilDone: false)

我无法编译更改。上述更改传达了信息

"Use of unresolved identifier performSelector.

我已经阅读了我能找到的有关此方法的所有内容,无论如何,它在 Swift 3 中似乎一团糟,但我只是在学习这门语言,我在应该是简单语法的东西上浪费了很多时间.

有人可以在这里提出建议吗?

TIA

最佳答案

不在withObject中它在with

试试这个

performSelector(onMainThread: #selector(importComplete), with: nil, waitUntilDone: false)

并将该方法称为

func importComplete() {
//
print("Hello World")
}

输出 enter image description here

关于iOS Swift 3 performSelector onMainThread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44299615/

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