Sanchit Paurush Sanchit Paurush - 2 months ago 14
Swift Question

Cannot invoke 'enumerateObjects' with an argument list of type '((AnyObject!, NSInteger, UnsafeMutablePointer<ObjCBool>) -> ())'

I am getting below error in my project at this line in Xcode 8 while it works fine in Xcode 7.

(self.columnHeights[section] as AnyObject).enumerateObjects({(object : AnyObject!, idx : NSInteger,pointer :UnsafeMutablePointer<ObjCBool>)


Error

Cannot invoke 'enumerateObjects' with an argument list of type '((AnyObject!, NSInteger, UnsafeMutablePointer<ObjCBool>) -> ())'


Please advice.

Answer

In Swift 3 most of the AnyObject types have been changed to Any

(self.columnHeights[section] as AnyObject).enumerateObjects({(object : Any, idx : Int, pointer :UnsafeMutablePointer<ObjCBool>) 

As always I'd recommend to use native Swift Array rather than Foundation NSArray to take advantage of the specific type information.

Comments