ios - 处理程序中源文件错误中的编辑器占位符
问题描述
我已经尝试了很多事情(将 _ :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))
}
解决方案
当您使用自动完成将模板代码添加到源文件中时,模板通常包含占位符或标有标记字符的字符串,您应该将其替换为用例的实际值。函数参数是最常见的例子。
示例:当我输入 时UIImage(named:
,Xcode 用完整的函数模板填充它,加上值的占位符。在 Xcode 之外查看,我得到的是:
UIImage(named: <#T##String#>)!
(请注意<#T##String#>
代表“类型变量String
”的位。)
但是,我在您发布的代码中看不到任何占位符。
推荐阅读
- javascript - 无法理解猫鼬虚拟中的“.this”
- java - 如何使用具有泛型和继承的方法?
- javascript - 使用 axios 渲染 ejs 时出现“无法读取数据属性错误”
- flutter - 将 Flutter 更新到 1.20.3-stable 后无法运行项目
- apache-kafka - 无法建立到节点 -1 的连接。经纪人可能不可用。Windows 和 WSL
- spring - Spring Security Roles Hierarchy Expression中的\是什么意思?
- mysql - MySQL - 根据团队成员返回多个用户
- java - 如何每个功能方法只执行一次设置方法/块?
- bash - 如何使用 bash 删除文本文件的镜像行
- terraform - Terraform 验收测试:“错误:无法读取文件”