Is objectAtIndexedSubscript available in IOS5?

前端 未结 4 1636
慢半拍i
慢半拍i 2021-01-03 09:25

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

4条回答
  •  情书的邮戳
    2021-01-03 10:04

    While objectAtIndexedSubscript: is not available previous to iOS 6, NSArray and NSDictionarysubscripting 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).

提交回复
热议问题