线程1断点1.1错误 - 迅速

时间:2015-12-23 23:18:00

标签: ios xcode swift uitableview

我正在研究这段代码。我必须在文本字段中显示用户名,但它显示错误,应用程序崩溃。

//
//  TableViewControllerSettings.swift
//  Secondo B
//
//  Created by Edoardo on 16/12/15.
//  Copyright © 2015 ERC. All rights reserved.
//

import UIKit
import Parse
import ParseUI

class TableViewControllerSettings: UITableViewController {

@IBOutlet weak var UserName: UILabel!

override func viewDidLoad() {

    super.viewDidLoad()

    self.UserName.text = "Bentornato " + (PFUser.currentUser()?.username)!

}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 2
}

@IBAction func Logout(sender: AnyObject) {

    PFUser.logOut()
    performSegueWithIdentifier("goto_tableLogin", sender: self)
    let alert = UIAlertView(title: "Logout", message: "Hai effettuato il logout", delegate: self, cancelButtonTitle: "OK")
    alert.show()

}

}

如何解决行中的问题

self.UserName.text =" Bentornato" ?

显示错误断点1.1

1 个答案:

答案 0 :(得分:2)

您必须声明numberOfRowsInSection委托方法

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    //return the number of rows
    return self.messagesArray.count
}