ios - Binary operator '!=' cannot be applied to operands of type 'Bool' and 'NilLiteralConvertible' -


binary operator '!=' cannot applied operands of type 'bool' , 'nilliteralconvertible'

getting error on if ((object.iskindofclass(nsdictionary)) != nil) {

let paramstring:nsmutablestring = nsmutablestring();                 (obj as! nsarray).enumerateobjectsusingblock({ (object, idx, stop) -> void in                     if ((object.iskindofclass(nsdictionary)) != nil){                         let pair:nsdictionary? = object as? nsdictionary;                         let textid:nsnumber? = pair?.objectforkey("textid") as? nsnumber;                         var content:nsstring? = pair?.objectforkey("content") as? nsstring;                          if ((content == nil) || (content?.length == 0) ) {                             content = " ";                         }                          if ((textid != nil) && (content != nil))    {                             paramstring.appendformat("%ld:%@\n", textid!.integervalue, content!);                         }                     }                 }); 

replace line:

if ((object.iskindofclass(nsdictionary)) != nil){ 

with line:

if object.iskindofclass(nsdictionary) { 

syntax iskindofclass is:

func iskindofclass(aclass: anyclass!) -> bool 

means iskindofclass return bool , can not compare nil. thats why compiler giving error.


Comments