Swift编译器错误 - 为'tableView'发出SIL时

Ren*_*enu 5 xcode uitableview ios swift

使用Xcode 6 Beta 5.我正在构建一个tableviewcontroller,这几行代码将无法编译.

func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell! 
{
    let cell : OrderHistoryCell = tableView.dequeueReusableCellWithIdentifier("CellForOrderHistory", forIndexPath: indexPath) as OrderHistoryCell

    var orderHistoryDataModel: OrderHistoryDataModel = self.orderItemsArray[indexPath.section][indexPath.row - 1] as OrderHistoryDataModel

    cell.nameLabel.text = orderHistoryDataModel.orderItem.title
    cell.statusLabel.text = orderHistoryDataModel.shipment.shippingStatus.toRaw()

    let imageData: NSData = NSData(contentsOfURL: orderHistoryDataModel.orderItem.imageURL)
    cell.thumbnailImageView.image = UIImage(data: imageData)

    return cell
}
Run Code Online (Sandbox Code Playgroud)

这是编译错误:

CompileSwift normal x86_64 com.apple.xcode.tools.swift.compiler
     ........ ............

 Stack dump: ....... ........
 intermediates/newProject.build/Debug-iphonesimulator/newProject.build/Objects-
 normal/x86_64/OrderHistoryViewController.o

 1. While emitting SIL for 'tableView' at /Users/testuser/Downloads/newProject/newProject/OrderHistoryViewController.swift:131:5
 <unknown>:0: error: unable to execute command: Segmentation fault: 11
 <unknown>:0: error: swift frontend command failed due to signal 
 (use -v to see invocation) Command /Applications/Xcode6-Beta5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
 failed with exit code 254
Run Code Online (Sandbox Code Playgroud)

Kos*_*val 15

这一行的问题

   var orderHistoryDataModel: OrderHistoryDataModel = self.orderItemsArray[indexPath.section][indexPath.row - 1] as OrderHistoryDataModel
Run Code Online (Sandbox Code Playgroud)

你有一个阵列数组OrderHistoryDataModel.
当你从2个数组中获取对象时,Xcode无法理解对象的类型 - [indexPath.section][indexPath.row - 1].
修复它 - orderItemsArray像这样 指定对象的类型

  var orderItemsArray: [[OrderHistoryDataModel]] = [] 
Run Code Online (Sandbox Code Playgroud)

您还可以尝试通过两个步骤获取对象.将此代码更改[indexPath.section][indexPath.row - 1]为:

var models: [OrderHistoryDataModel] = self.orderItemsArray[indexPath.section]
var orderHistoryDataModel: OrderHistoryDataModel =  models[indexPath.row - 1]
Run Code Online (Sandbox Code Playgroud)

同时清除项目并删除DerivedData文件夹.