macOS/iOS API解説

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

目次

setWithObjects:count:

INDEX>Foundation>NSSet

オブジェクトの配列と配列数でセットを作って返します
+(id)setWithObjects:(id *)objects
       count:(unsigned)count

解説

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

返り値

( id )

セットオブジェクト

引数

( id * )objects

オブジェクト

( unsigned )count

カウント

クラス

NSSet

Class Methods

使用可能

10.0
iOS2.0

参照

- set
+ setWithArray:
- setWithObject:
- setWithObjects:

例文

#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 setWithObjects:(id *)valArr count:theCount];
NSLog([[set allObjects] description]);

}

@end