The documentation says it\'s available in MacOS 1.08.
So what\'s the story? What about for iOS5?
It\'s a very important selector because self[5] will actuall
No, only since iOS 6 unfortunately.
Apple has separate documentations for the OS X and the iOS APIs. You have to check the right one: objectAtIndexedSubscript:.
Availability
Available in iOS 6.0 and later.
I look at the NSOrderedSet.h file and I saw this:
- (id)objectAtIndexedSubscript:(NSUInteger)idx NS_AVAILABLE(10_8, 6_0);
So it doesn't work for IOS5.
If you need your code to run on iOS 5, you'll need to replace
myOrderedSetOfHilariousAcronyms[2] = @"ROFL";
with
[myOrderedSetOfHilariousAcronyms setObject:@"ROFL" atIndex:2];
While objectAtIndexedSubscript:
is not available previous to iOS 6, NSArray
and NSDictionary
subscripting is available. That means that you can use syntax like this:
myArray[2] = @"thingie";
myDictionary[@"roger"] = @"barry";
And it will deploy back to iOS 4.
However NSOrderedSet
subscripting will not work on iOS 5 and previous. For that, you will need to provide a category that redirects objectAtIndexedSubscript:
calls to objectAtIndex:
.
Addendum: Apple's docs for NSMutableOrderedSet
are also incorrect. It states that index subscripting does an insert, when in reality is does a replace (as one would expect).