Bool does not convert to ObjCBool

I am getting this error:

return (index == self.pagesTitles.count || index == NSNotFound) ? nil : viewControllerAtIndex(++index)

      

Bool does not convert to ObjCBool

I wanted to do ternary operator to simplify things. Something is wrong?

+3


source to share


1 answer


Make sure you have specified the type of the returned object correctly. In your case, a UIViewController?



func myMethod() -> UIViewController? {
    return (index == self.pagesTitles.count || index == NSNotFound) ? nil : viewControllerAtIndex(++index)
}

      

0


source







All Articles