Is the new Xcode 7 generics feature for Objective C a compiler feature or does it require iOS 9?
Can I target iOS 8, but still use generics?
It's a compiler feature. All that happens when you declare e.g. NSArray<NSString *> *
is that the compiler will then pretend that instead of - addObject:(id)
you've got - addObject:(NSString *)
, generating appropriate messages if you supply the wrong type of argument.
It's still Objective-C and everything is still all dynamically typed. There's only one implementation of NSArray
, which is always used regardless of generics, and is the same as it ever was. No code generation occurs, no dynamic runtime shenanigans occur.
Furthermore this is true of all classes, not merely NSArray
. The 'lightweight' in Apple's lightweight generics means you're supplying compile-time hints only.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With