Xcode 7 contains an Objective-C variant, where you can define a type-hint for (homogenous) NSArray
return values and properties, defined such as NSArray&l
The lightweight generics introduced in Xcode 7 are just compile time hints to help the compiler raise warnings, but at run time you get the same old behavior with your variable being just NSArray
s of id
s.
Source: WWDC '15 "Swift and Objective-C Interoperability" session
See the transcript of the talk:
So the entire lightweight generics feature is based on a type erasure model. Which means that the compiler has all of this rich static type information but it erases that information when generating code.
It is not possible to do that.
Generics were introduced in objective-c to improve the bridge between swift and objective-c. The advantage it gives to objective-c is only useful at compile time, and I that information is lost at runtime.