3
我得到這個錯誤做:布爾是無法轉換爲ObjCBool
return (index == self.pagesTitles.count || index == NSNotFound) ? nil : viewControllerAtIndex(++index)
布爾是無法轉換爲ObjCBool
我想做一個三元運營商簡化的東西。有什麼不對 ?
我得到這個錯誤做:布爾是無法轉換爲ObjCBool
return (index == self.pagesTitles.count || index == NSNotFound) ? nil : viewControllerAtIndex(++index)
布爾是無法轉換爲ObjCBool
我想做一個三元運營商簡化的東西。有什麼不對 ?
確保您正確指定了返回對象的類型。在你的情況UIViewController?
func myMethod() -> UIViewController? {
return (index == self.pagesTitles.count || index == NSNotFound) ? nil : viewControllerAtIndex(++index)
}
什麼是索引類型?爲什麼你需要將NSNotFound包含在這裏? – 2014-08-29 08:12:29
嘗試將值存儲在「temp」變量中,然後將其返回。 'let rValue = UTTypeConformsTo(utiCF,typeCF)!= 0 rValue =(index == self.pagesTitles.count || index == NSNotFound)? nil:viewControllerAtIndex(++ index) return rValue ' – 2014-08-29 08:17:47
我試過它在Xcode-beta6中,它的工作。 'let index = 10 let count = 20 let result =(index == count || index == NSNotFound) ' – 2014-08-29 11:43:55