首页 > 解决方案 > 处理程序中源文件错误中的编辑器占位符

问题描述

我已经尝试了很多事情(将 _ :UIAlertAction 放在 openPage func 和处理程序内部尝试不同的关闭等)但是当没有编辑器占位符错误时,我得到另一个错误。

什么是“源文件中的 Edtor 占位符”可能的错误和解决方案

@objc func resenje(){
    let ac = UIAlertController (title: "Prikaz dodavanja drugog tab-a", message: "Zbog novije verzije xCode-a", preferredStyle: .actionSheet)
    ac.addAction(UIAlertAction(title: "https://www.reddit.com",
                               style: .default,
                               handler:{ [weak self] action in self?.openPage() })) 
                                       //Editor placeholder in source file !
    ac.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
    present(ac, animated: true)
}
func openPage(){
    let url = URL(string: title!)!
    webView.load(URLRequest(url: url))
}

标签: iosswift

解决方案


当您使用自动完成将模板代码添加到源文件中时,模板通常包含占位符或标有标记字符的字符串,您应该将其替换为用例的实际值。函数参数是最常见的例子。

示例:当我输入 时UIImage(named:,Xcode 用完整的函数模板填充它,加上值的占位符。在 Xcode 之外查看,我得到的是:

UIImage(named: <#T##String#>)!

(请注意<#T##String#>代表“类型变量String”的位。)

但是,我在您发布的代码中看不到任何占位符。


推荐阅读