Get Subscripting for iOS Today

When I watched the WWDC video for Modern Objective-C, I was really excited to see that they had made some really cool changes to make the language much less verbose and much simpler.

Objective-C now supports subscripting for NSDictionaries and NSArrays. Here is a simple example comparing the old versus the new way of creating an NSDictionary:

All this syntactic sugar is available in Xcode 4.4, but I quickly learned that even though the compiler can support this syntax, SDK support (Mac OS X has it iOS does not) is still required.

So after some googling around I saw this article and found out that all that was needed was that it is possible by providing a header file with the following methods:

Word of caution when using this interface; you will be able to use the subscript syntax with EVERY type. Try and use this with a class that doesn't support it and, you guessed it, runtime error . (

Hopefully next year Apple will make even more changes to Objective-C. Maybe we'll see something like this: