how can i put these print text into Textfield?

我是研究僧i 提交于 2019-12-02 13:40:49

You are using $0 inside async { } closure. This closure expects no arguments, which means using $0 argument shortcut is invalid.

You are evidently attempting to refer to requests array from getPendingNotificationRequests callback. The reason you can't by using $0 is that it's screened by DispatchQueue.main.async{ ... } closure with no arguments:

Try this:

    UNUserNotificationCenter.current().getPendingNotificationRequests { requests in
        DispatchQueue.main.async{
            let str:String = ""
            self.finalresulter.text = str
            self.finalresulter.text = "\(requests.map{$0.content.title})"
        }
    }

The rule for $0 claims that $0 always refers to current scope. Thus, to access closure argument from nested closure, that argument must be named (requests in the above code).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!