尝试解包可选值时出错

时间:2015-03-26 20:56:11

标签: swift

import  UIKit

class About: UITableViewController {
    var FollowUpArray = [String]()
    var aboutUsArray = [String] ()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        aboutUsArray = ["hello","hello","hello"]
        FollowUpArray = ["hello1","hello2","hello3"]
    }

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

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var Cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! UITableViewCell

        Cell.textLabel?.text = aboutUsArray[indexPath.row]

        return Cell
    }

    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

        var indexPath : NSIndexPath = self.tableView.indexPathForSelectedRow()!
  

致命错误:在解包可选值时意外发现nil

        var DestViewController = segue.destinationViewController as! AboutUss

        DestViewController.FirstString = FollowUpArray[indexPath.row]
    }

当我想从此表视图返回到另一个视图控制器Xcode不允许它时发生致命错误。

0 个答案:

没有答案