我的UITableView數據源和委託沒有連接到任何文件。如果這是問題,有人會告訴我如何連接它們。如果沒有,這是我的代碼。包含結構信息表格單元格爲空Swift
我的文件:
struct PreviousApps {
var name : String
var description : String
var filename : String
}
這是我在我的TableViewController代碼:
import UIKit
class PreviousProjectsVC: UIViewController, UITableViewDelegate, UITableViewDataSource{
var apps = [PreviousApps]()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
var PreviousApp = PreviousApps(name: "Gecko Catch", description: "DESCRIPTION", filename: "geckocatch.png")
apps.append(PreviousApp)
PreviousApp = PreviousApps(name: "Flappy Timothy", description: "DESCRIPTION", filename: "flappytimothy.png")
apps.append(PreviousApp)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
var currentApp = apps[indexPath.row]
cell.textLabel!.text = currentApp.name
return cell
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return apps.count
}
}
我是新來的斯威夫特和任何幫助,將不勝感激。如果我不夠具體,告訴我,我會盡力爲您提供更多信息。
感謝, 貝克
您是否使用故事板並拖動tableviewcontroller? – Leo
「如果這是問題」 - 嚴重?? SO不能替代閱讀文件。 – rdelmar
@rdelmar我已閱讀文檔並瞭解網點,我只是不知道如何連接代理或數據源。 – ThatComputerNerd