Instance Method インスタンスメソッド

indexOfObjectAtIndexes:options:passingTest:

Returns the index, from a given set of indexes, of the first object in the array that passes a test in a given block for a given set of enumeration options. 配列の中の最初のオブジェクトのインデックスを、与えられた一揃いのインデックスから返します、それは、与えられた「ブロック」の中のテストを一式の与えられた列挙オプションで合格したものです。

Declaration 宣言

- (NSUInteger)indexOfObjectAtIndexes:(NSIndexSet *)s 
                             options:(NSEnumerationOptions)opts 
                         passingTest:(BOOL (^)(ObjectType obj, NSUInteger idx, BOOL *stop))predicate;

Parameters パラメータ

indexSet

The indexes of the objects over which to enumerate. それらを1つ1つ列挙していくことになるいくらかのオブジェクトのインデックス。

opts

A bit mask that specifies the options for the enumeration (whether it should be performed concurrently and whether it should be performed in reverse order). あるビットマスク、それは、列挙のためのオプションを指定します(それが並行に実行されるべきかどうかそしてそれが逆順に実行されるべきかどうか)。

predicate

The block to apply to elements in the array. 配列の中の要素に適用されることになるブロック。

The block takes three arguments: ブロックは、次の3つの引数をとります:

obj

The element in the array. 配列の中の要素。

idx

The index of the element in the array. 配列の中の要素のインデックス。

stop 中止

A reference to a Boolean value. The block can set the value to YES to stop further enumeration of the array. If a block stops further enumeration, that block continues to run until it’s finished. When the NSEnumerationConcurrent enumeration option is specified, enumeration stops after all of the currently running blocks finish. The stop argument is an out-only argument. You should only ever set this Boolean to YES within the block. あるブール値への参照。ブロックはYESに設定されることで、それ以上の配列の処理を止めることができます。あるブロックがその先の列挙を止めるならば、そのブロックはそれがやり終えられるまで実行を継続します。NSEnumerationConcurrent列挙オプションが指定される場合、列挙は、現在実行しているいくつかのブロックすべてがやり終える後に停止します。stop引数は、ひとつの退出専用引数です。あなたは、常に「ブロック」内部でこのブールをYESに設定できるだけであるべきです。

The block returns a Boolean value that indicates whether obj passed the test. この「ブロック」はobjがテストを合格したかどうかを示すブール値を返します。

Return Value 戻り値

The lowest index whose corresponding value in the array passes the test specified by predicate. If no objects in the array pass the test, returns NSNotFound. 配列の中のそれの対応する値がpredicateによって指定されるテストを合格する最も低いインデックス。配列の中にテストを合格するオブジェクトが1つもないならば、NSNotFoundを返します。

Discussion 議論

By default, the enumeration starts with the first object and continues serially through the array to the last element specified by indexSet. You can specify NSEnumerationConcurrent and/or NSEnumerationReverse as enumeration options to modify this behavior. 初期状態では、列挙は最初のオブジェクトで開始して順次その配列をindexSetで指定される最後の要素まで続けます。あなたは、NSEnumerationConcurrentおよび/またはNSEnumerationReverseを列挙オプションとして指定してこの挙動を変えることができます。

See Also 参照

Finding Objects in an Array 配列内のオブジェクトを見つける