2015-03-11 8 views
10

"बाइनरी ऑपरेटर '==' प्रकार सेल और शून्य की ऑपरेंड के लिए लागू नहीं किया जा सकता" मैं Xcode 6.3 का उपयोग कर बीटा पार्स/स्विफ्ट के साथ एक मुद्दापार्स/स्विफ्ट जारी करना

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 
    } 

त्रुटि बताया है

if cell == nil 
     { 
      cell = secTableViewCell(style: UITableViewCellStyle.Default , reuseIdentifier: "cell") 
     } 

द्विआधारी ऑपरेटर के लिए '==' प्रकार सेल के ऑपरेंड के लिए और नहीं के बराबर "

उत्तर

18

cell प्रकार secTableViewCell की है लागू नहीं किया जा सकता है नहीं secTableViewCell? (012,)। क्योंकि यह एक वैकल्पिक नहीं है, यह शून्य नहीं हो सकता है।

आप nil के लिए परीक्षण की आवश्यकता है, तो आप

var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as? secTableViewCell 

बात आप nil के लिए परीक्षण करने के लिए कभी नहीं होना चाहिए है करना चाहते हैं। "सेल" हमेशा एक ही प्रकार का होना चाहिए (आपके मामले में यह हमेशा secTableViewCell होना चाहिए।

संबंधित मुद्दे