The reason you get this error (even in a class that inherits from NSObject
) is because some Swift types cannot be represented in Objective-C, such as an array of enums.
[[NSLayoutAttribute]]
will not work but [[Int]]
will because while Array<SomeEnumType>
cannot be bridged, an array of Int
s are implicitly bridged to an NSArray
of NSNumber
objects through Foundation.
Yoav Schwartz's answer is wrong because Objective-C objects can have arrays of things that are not NSObject
s. Look at C arrays: NSUInteger someNums[5] = {1, 2, 3, 4, 5};
is valid in Objective-C. NSArray
s however, cannot hold value types and must hold objects.