Swift:如何在应用程序后台运行异步方法

问题描述 投票:0回答:0

我想以正确的方式运行以下代码:

public func function1() {
    Task {
        await asyncFunc()
        // asyncFunc is a async function we wouldn't like to wait till it finish, we would like it to run in the background
    }
}

此功能有效但会导致内存泄漏 我想在应用程序后台运行异步功能

asyncFunc

swift asynchronous
© www.soinside.com 2019 - 2024. All rights reserved.