2017-01-12 41 views
-3

編譯錯誤這是我的viewController 的UITableView中的AppDelegate斯威夫特

import UIKit 

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { 

    let list = ["Facebook: 2000$", "Twitter: 10000$", "Vine: 23356$", "Uber: 35000", "Adobe Systems: 400900", "Agilent Tech: 456700", "Ebay: 98899"] 

    public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
    { 
     return (list.count) 
    } 

    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 
    { 
     let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "cell") 
     cell.textLabel?.text = list[indexPath.row] 
     return(cell) 
    } 

    override func viewDidLoad() { 
     super.viewDidLoad() 
     // Do any additional setup after loading the view, typically from a nib. 
    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 
} 

和我的應用程序委託:

import UIKit 
import CoreData 

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate { 

    var window: UIWindow? 


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
     // Override point for customization after application launch. 
     return true 
    } 

    func applicationWillResignActive(_ application: UIApplication) { etc.. 

我在做什麼錯?

+4

有什麼錯誤? –

+0

請解釋你面臨的問題。 – Adeel

+0

我的問題是,當我嘗試運行它時,在appdelegate中有4行存在編譯錯誤。 –

回答

0

可能缺失對

override func viewDidLoad() { 
    super.viewDidLoad() 
    yourTableView.delegate = self 
    yourTableView.dataSource = self 
} 
+1

不給'委託'和'datasource'到'self'永遠不會給出錯誤,但你的委託方法永遠不會調用 –