- objectEnumerator
- enumerateKeysAndObjectsUsingBlock:
- enumerateKeysAndObjectsWithOptions:usingBlock:
- countByEnumeratingWithState:objects:count:
Availability 有効性
Technology
- (NSEnumerator
<KeyType > *)keyEnumerator;
An enumerator object that lets you access each key in the dictionary. あなたに辞書の中の各キーにアクセスさせる列挙子オブジェクト。
Here’s how you might use this method. ここにどのようにあなたがこのメソッドを使うかもしれないかがあります。
NSEnumerator *enumerator = [myDictionary keyEnumerator];
id key;
while ((key = [enumerator nextObject])) {
/* code that uses the returned key */
}
If you use this method with instances of mutable subclasses of NSDictionary
, your code should not modify the entries during enumeration. If you intend to modify the entries, use the all
property to create a “snapshot” of the dictionary’s keys. Then use this snapshot to traverse the entries, modifying them along the way.
あなたがこのメソッドをNSDictionary
の可変サブクラスのインスタンスとともに使うならば、あなたのコードは列挙の間に登録項目を修正すべきではありません。あなたが登録項目それらを修正するつもりならば、all
メソッドを使うことでその辞書の持つキーそれらの “スナップショット” を作成してください。それからこのメソッドを使って登録項目それらを辿っていってください、それらを途中で修正しながら。
If you want to enumerate the dictionary’s values rather than its keys, use the object
method.
あなたが辞書のもつ値をそれのキーではなく列挙したいならば、object
メソッドを使ってください。
It is more efficient to use the fast enumeration protocol (see NSFast
) than this method. Fast enumeration is available in macOS 10.5 and later and iOS 2.0 and later.
より効率的なのは、高速列挙プロトコルを使うことです(NSFast
を見てください)このメソッドより。高速列挙は、macOS 10.5以降とiOS 2.0以降で利用可能です。
- objectEnumerator
- enumerateKeysAndObjectsUsingBlock:
- enumerateKeysAndObjectsWithOptions:usingBlock:
- countByEnumeratingWithState:objects:count: