UISearchController
セルのカスタム スタイルを定義しようとしています (しかしできません) 。以下のコードを実行すると、EXC_BAD_INSTRUCTION
その行でエラーが発生しますcell.textlabel?.text
。ここで完全に明らかな何かが欠けていますか?
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell!
if (cell != nil) {
cell = UITableViewCell(style: UITableViewCellStyle.Value1, reuseIdentifier: "Cell")
}
if (tableView == self.searchDisplayController?.searchResultsTableView) {
let data: AnyObject = self.searchResults.objectAtIndex(indexPath.row) as AnyObject
println("searchresults: \(data)")
cell.textLabel?.text = data.valueForKeyPath("name") as? String
cell.detailTextLabel?.text = data.valueForKeyPath("placemark") as? String
}
return cell
}