Type Method 型メソッド

arrayWithObjects:count:

Creates and returns an array that includes a given number of objects from a given C array. 指定された数のオブジェクトをある与えられたC配列から含む配列を作成して返します。

Declaration 宣言

+ (instancetype)arrayWithObjects:(ObjectType  _Nonnull const *)objects 
                           count:(NSUInteger)cnt;

Parameters パラメータ

objects

A C array of objects. オブジェクトのC配列。

count

The number of values from the objects C array to include in the new array. This number will be the count of the new array—it must not be negative or greater than the number of elements in objects. objects C配列から新しい配列の中に含めることになる値の数。この数は、新しい配列の総数になります—それは負であったりobjectsの中の要素の数を上回ったりしてははなりません。

Return Value 戻り値

A new array including the first count objects from objects. objectsから最初のcount個のオブジェクトを含んでいる新しい配列。

Discussion 議論

Elements are added to the new array in the same order they appear in objects, up to but not including index count. For example: 要素は、それらがobjectsにおいて現れるのと同じ順序で、インデックスcountまで、しかしそれを含めずに、新しい配列に加えられます。例えば:


NSString *strings[3];
strings[0] = @"First";
strings[1] = @"Second";
strings[2] = @"Third";
 
NSArray *stringsArray = [NSArray arrayWithObjects:strings count:2];
// strings array contains { @"First", @"Second" }

See Also 参照

Creating an Array 配列の作成

Related Documentation 関連文書