0
林學習迅速,現在,其具有下列問題 請幫助..不能調用「functionName」類型的斯威夫特Xcode中的參數列表「([(nameOfClass)])」 6.3.1
我有3個類 - TableViewController BroadcastModel BroadcastRequest 我得到以下錯誤(錯誤的行標有註釋) 不能援引「requestFinished」有型「([(BroadcastModel)])」
import UIKit
public class TableViewController: UITableViewController {
var broadcasts = [BroadcastModel]()
//MARK: ViewControllerLifecycle
override public func viewDidLoad() {
super.viewDidLoad()
//maybe will use the 2d array for sections of broadcasts..
BroadcastRequest().requestNewBroadcasts()
}
public func requestFinished(requestedBroadcasts: [BroadcastModel]) {
self.broadcasts = requestedBroadcasts \* HERE IS THE ERROR *\
self.tableView.reloadData()
}
public class BroadcastRequest {
func requestNewBroadcasts() {
var broadcasts = [BroadcastModel]()
.....
.....
broadcasts.append(broadcast)
TableViewController.requestFinished(broadcasts)
}
}
public class BroadcastModel: NSObject, Printable {
let id: String
let broadcastURL: String
...
...
override public var description: String {
return "ID: \(id), URL: \(broadcastURL) ....."
}
init(...) {
...
}
}
參數列表
試過。我現在得到以下錯誤 - 1)'TableViewController.Type'沒有名爲'broadcasts'的成員 2)不能調用'reloadData'沒有參數 – user2993422
@ user2993422看起來你的代碼的邏輯不正確,如果你做我所說的,你不能在課堂上使用自己的功能 – duan
忘記我之前說過的話。我建議你刪除'BroadcastRequest'和'BroadcastModel'並將'requestNewBroadcasts'函數轉換成類'TableViewController' – duan