Share via


NSObjectFlag 클래스

정의

MonoTouch 프레임워크에서 사용하는 Sentinel 클래스입니다.

public class NSObjectFlag
type NSObjectFlag = class
상속
NSObjectFlag

설명

NSObjectFlag 클래스의 유일한 목적은 NSObject 클래스 계층 구조에서 sentinel로 사용하여 실제 개체 초기화가 NSObject에서만 수행되도록 하는 것입니다.

NSObjectFlag를 사용하여 생성자를 연결하면 개체 인스턴스의 할당만 수행됩니다. 기본 클래스의 메서드는 init에 대한 호출이 수행되지 않습니다. 코드가 초기화를 위해 이에 의존하는 경우 적절한 init 메서드를 직접 호출해야 합니다. 예를 들면 다음과 같습니다.

// 
// The NSObjectFlag merely allocates the object and registers the
// C# class with the Objective-C runtime if necessary, but no actual
// initXxx method is invoked, that is done later in the constructor
//
// This is taken from Xamarin's source code:
//
[Export ("initWithFrame:")]
public UIView (System.Drawing.RectangleF frame) : base (NSObjectFlag.Empty)
{
	// Invoke the init method now.
	var initWithFrame = new Selector ("initWithFrame:").Handle;
	if (IsDirectBinding) {
		Handle = ObjCRuntime.Messaging.IntPtr_objc_msgSend_RectangleF (this.Handle, initWithFrame, frame);
	} else {
		Handle = ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_RectangleF (this.SuperHandle, initWithFrame, frame);
	}
}

또는 자신을 초기화하기 위해 기본 클래스가 필요한 경우 일부 매개 변수를 사용하는 다른 생성자 중 하나를 호출해야 합니다.

class MyViw : UIView {
	[Export ("initWithFrame:")]
	public MyView (RectangleF frame) : base (frame)
	{
		// this initialized MyView by calling the UIView constructor
		// that initializes the object from a RectangleF frame.
	}
}

필드

Empty

Sentinel 인스턴스.

적용 대상