macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

initWithObjects:count:

オブジェクトの配列と配列数でセットを初期化して返します
-(id)initWithObjects:(id *)objects
       count:(unsigned)count

解説

オブジェクトの配列と配列数でセットを初期化して返します。

返り値

( id )

セット

引数

( id * )objects

オブジェクト

( unsigned )count

カウント

クラス

NSSet

Instance Methods

使用可能

10.0

参照

- initWithArray:
- initWithObjects:
- initWithSet:
- initWithSet:copyItems:
+ setWithObjects:count:

例文

#import "MyObject.h"

@implementation MyObject

- (IBAction)myAction:(id)sender
{
static const int theCount = 3;

NSNumber *valArr[theCount];
int i;
for (i = 0; i < theCount; i++) {

    valArr[i] = [NSNumber numberWithInt:i];
}

NSSet *set = [[NSSet alloc] initWithObjects:(id *)valArr count:theCount];
NSLog([[set allObjects] description]);

}

@end