Re:Xcode 4.4 is available (for Lion and Mountain Lion)
by hboon on Thursday July 26, 2012 @01:08AM
(#4294509)
Literals and object/container subscripting are different things, even though they appear at the same time. Container literals should be compile time too and available to all versions of iOS (or at least v4 and above).
I also think it should be possible to support container (NSArray, NSDictionary) subscripting for foundation classes at compile-time for all versions even if the new functions aren't around. They just have to translate to the existing functions. I bet they do this too[1]
(upvoted you, it is a very informative link).
Edit: some more thoughts.
[1] No, they don't do that in v4.4. But maybe they will in a future version of Xcode.
Re:Xcode 4.4 is available (for Lion and Mountain Lion)
by woadwarrior01 on Thursday July 26, 2012 @01:15AM
(#4294525)
Thanks for the link. I was wondering if they'd implemented type-inference to check what method to call for the indexing operator since the operand could be either an NSArray or a NSDictionary. It turns out they've elided the whole problem altogether by doing this at runtime with new methods. Given how dynamic objective-c is, this seems like the best way to go about it.
Mike Ash goes into some detail on his excellent blog: http://www.mikeash.com/pyblog/friday-qa-2012-06-22-objective...
Long story short, some of it is compile time, but some of it involves classes in Foundation (like NSArray and NSDictionary) implementing new methods (like objectAtIndexedSubscript).
iOS needs a base SDK update before those methods will be available there. Or you could monkey-patch them in with a category yourself in the meantime.