Share via


NSTrackingArea.EncodeTo(NSCoder) Method

Definition

Encodes the state of the object using the provided encoder.

[Foundation.Export("encodeWithCoder:")]
[ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)]
public virtual void EncodeTo(Foundation.NSCoder encoder);
[<Foundation.Export("encodeWithCoder:")>]
[<ObjCRuntime.BindingImpl(ObjCRuntime.BindingImplOptions.GeneratedCode | ObjCRuntime.BindingImplOptions.Optimizable)>]
abstract member EncodeTo : Foundation.NSCoder -> unit
override this.EncodeTo : Foundation.NSCoder -> unit

Parameters

encoder
NSCoder

The encoder object where the state of the object will be stored

Implements

Attributes

Remarks

This method is part of the INSCoding protocol and is used by applications to preserve the state of the object into an archive.

Developers will typically create an NSKeyedArchiver and then invoke the ArchiveRootObjectToFile(NSObject, String) method which will call into this method.

If developers want to allow their object to be archived, they should override this method and store their state in using the provided encoder parameter. In addition, developers should also implement a constructor that takes an NSCoder argument and is exported with [Export ("initWithCoder:")].

public void override EncodeTo (NSCoder coder) {
            coder.Encode (1, key: "version");
            coder.Encode (userName, key: "userName");
            coder.Encode (hostName, key: "hostName");

Applies to