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

replacementObjectForPortCoder:

Overridden by subclasses to substitute another object or a copy for itself during distribution encoding.

Declaration 宣言

- (id)replacementObjectForPortCoder:(NSPortCoder *)coder;

Parameters パラメータ

aCoder

The port coder encoding the receiver.

Return Value 戻り値

The object encode instead of the receiver (if different). エンコードするオブジェクト、レシーバの代理(異なるならば)。

Discussion 解説

This method is invoked by NSPortCoder. NSObject’s implementation returns an NSDistantObject object for the object returned by replacementObjectForCoder:, enabling all objects to be distributed by proxy as the default. However, if replacementObjectForCoder: returns nil, NSObject’s implementation will also return nil.

Subclasses that want to be passed by copy instead of by reference must override this method and return self. The following example shows how to support object replacement both by copy and by reference:


- (id)replacementObjectForPortCoder:(NSPortCoder *)encoder {
    return [encoder isByref] ? [super replacementObjectForPortCoder:encoder] : self;
}

See Also 参照

Deprecated Methods 非推奨メソッド

Related Documentation 関連文書