I've an issue with Parse/Swift using Xcode 6.3 beta
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath , object: PFObject) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! secTableViewCell
if cell == nil
{
cell = secTableViewCell(style: UITableViewCellStyle.Default , reuseIdentifier: "cell")
}
// Configure the cell...
cell.title.text = (object["exams"] as! String)
cell.img.image = UIImage(named: "109.png")
return cell
}
The Error pointed to
if cell == nil
{
cell = secTableViewCell(style: UITableViewCellStyle.Default , reuseIdentifier: "cell")
}
binary operator '==' cannot be applied to operands of type cell and nil"
cell is of type secTableViewCell not secTableViewCell? (Optional<secTableViewCell>). Because it's not an optional, it cannot be nil.
If you need to test for nil, then you want to have
var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as? secTableViewCell
The thing is you should never have to test for nil. "cell" should always be the same type (in your case it should alway be secTableViewCell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With