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

initWithSet:copyItems:

Initializes a newly allocated set and adds to it members of another given set. 新しくアロケートされた集合を初期化して、それに別の与えられた集合のメンバを加えます。

Declaration 宣言

- (instancetype)initWithSet:(NSSet<ObjectType> *)set 
                  copyItems:(BOOL)flag;

Parameters パラメータ

set

A set containing objects to add to the new set. 新しい集合に加えることになるオブジェクトを含んでいる集合。

flag

If YES, each object in set receives a copyWithZone: message to create a copy of the object—objects must conform to the NSCopying protocol. In a managed memory environment, this is instead of the retain message the object would otherwise receive. The object copy is then added to the returned set. YESならば、setの中の各オブジェクトはcopyWithZone:メッセージを受け取って、そのオブジェクトのコピーを作成します—オブジェクトはNSCopyingプロトコルに準拠しなければなりません。管理されたメモリ環境では、これは、そうでなければオブジェクトが受け取るであろうretainメッセージの代わりです。オブジェクトのコピーはそれからその返される集合に加えられます。

If NO, then in a managed memory environment each object in set simply receives a retain message when it is added to the returned set. NOならば、それから管理されたメモリ環境ではsetの各オブジェクトは、それがその返される集合に加えられる時に単にretainメッセージを受け取ります。

Return Value 戻り値

An initialized set that contains the members of set. The returned set might be different than the original receiver. ある初期化された集合、それはsetのメンバを含みます。返される集合は、オリジナルのレシーバとは異なるかもしれません。

Discussion 議論

After an immutable s has been initialized in this way, it cannot be modified. 不変の集合がこの方法で初期化され終わった後は、それは修正されることはできません。

The copyWithZone: method performs a shallow copy. If you have a collection of arbitrary depth, passing YES for the flag parameter will perform an immutable copy of the first level below the surface. If you pass NO the mutability of the first level is unaffected. In either case, the mutability of all deeper levels is unaffected. copyWithZone:メソッドは、浅いコピーを行います。あなたが随意の深さのあるコレクションを持つならば、YESflagパラメータに渡すことは表面下の第一階層の不変のコピーを行うことになります。あなたがNOを渡すならば第一階層の可変性は影響を受けません。両方の場合とも、すべてのより深い階層の可変性は影響を受けません。

See Also 参照

Initializing a Set 集合を初期化する

Related Documentation 関連文書