目前,我正在为我的移动应用设计类(class)制作一个抽认卡应用。这是我的 SearchController.swift 文件代码
import UIKit
class SearchController: UIViewController {
@IBOutlet weak var webView: UIWebView!
var flashcard: Flashcard?
let baseSearchURL = "https://google.com/search?q=apple developer"
override func viewDidLoad() {
super.viewDidLoad()
if let card = flashcard,
let escapedURLString = searchURLString(baseSearchURL, term: card.term),
let url = URL(string: escapedURLString) {
webView.loadRequest(URLRequest(url: url))
}
}
fileprivate func searchURLString(_ base: String, term: String) -> String? {
return "\(baseSearchURL) \(term)"
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
}
}
行:
let escapedURLString = searchURLString(baseSearchURL, term: card.term)
给出一个错误提示
"Missing argument label 'base:' in call"
行:
return "\(baseSearchURL) \(term)"
给出一个错误提示
"Static member 'init(stringInterpolationSegment' cannot be used on instance type of 'String'"
知道如何解决这个问题吗?
你要回来了
return "\(baseSearchURL) \(term)"
这里你应该返回 base
而不是 baseSearchURL
之类的,
return "\(base) \(term)"
缺少参数错误应该像这样解决,
searchURLString(base: baseSearchURL, term: card.term)
关于ios - Swift 3 - 多 View Controller 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40145784/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |