次の方法で共有


EAAccessoryManager.Notifications.ObserveDidConnect メソッド

定義

オーバーロード

ObserveDidConnect(EventHandler<EAAccessoryEventArgs>)

定数に対して DidConnectNotification 厳密に型指定された通知。

ObserveDidConnect(NSObject, EventHandler<EAAccessoryEventArgs>)

定数に対して DidConnectNotification 厳密に型指定された通知。

ObserveDidConnect(EventHandler<EAAccessoryEventArgs>)

定数に対して DidConnectNotification 厳密に型指定された通知。

public static Foundation.NSObject ObserveDidConnect (EventHandler<ExternalAccessory.EAAccessoryEventArgs> handler);
static member ObserveDidConnect : EventHandler<ExternalAccessory.EAAccessoryEventArgs> -> Foundation.NSObject

パラメーター

handler
EventHandler<EAAccessoryEventArgs>

通知が投稿されたときに呼び出すメソッド。

戻り値

通知を破棄するか、またはに渡すことによって通知の受信を停止するために使用できるトークン オブジェクト RemoveObservers(IEnumerable<NSObject>)

注釈

次の例は、開発者がコードでこのメソッドを使用する方法を示しています。

//
// Lambda style
//

// listening
notification = EAAccessoryManager.Notifications.ObserveDidConnect ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("Accessory", args.Accessory);
    Console.WriteLine ("Selected", args.Selected);
});

// To stop listening:
notification.Dispose ();

//
//Method style
//
NSObject notification;
void Callback (object sender, ExternalAccessory.EAAccessoryEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("Accessory", args.Accessory);
    Console.WriteLine ("Selected", args.Selected);
}

void Setup ()
{
    notification = EAAccessoryManager.Notifications.ObserveDidConnect (Callback);
}

void Teardown ()
{
    notification.Dispose ();
}

適用対象

ObserveDidConnect(NSObject, EventHandler<EAAccessoryEventArgs>)

定数に対して DidConnectNotification 厳密に型指定された通知。

public static Foundation.NSObject ObserveDidConnect (Foundation.NSObject objectToObserve, EventHandler<ExternalAccessory.EAAccessoryEventArgs> handler);
static member ObserveDidConnect : Foundation.NSObject * EventHandler<ExternalAccessory.EAAccessoryEventArgs> -> Foundation.NSObject

パラメーター

objectToObserve
NSObject

観察するオブジェクト。

handler
EventHandler<EAAccessoryEventArgs>

通知が投稿されたときに呼び出すメソッド。

戻り値

通知を破棄するか、またはに渡すことによって通知の受信を停止するために使用できるトークン オブジェクト RemoveObservers(IEnumerable<NSObject>)

注釈

このメソッドは、通知を DidConnectNotification サブスクライブするために使用できます。

// Listen to all notifications posted for any object
var token = EAAccessoryManager.Notifications.ObserveDidConnect ((notification) => {
	Console.WriteLine ("Observed DidConnectNotification!");
};

// Listen to all notifications posted for a single object
var token = EAAccessoryManager.Notifications.ObserveDidConnect (objectToObserve, (notification) => {
	Console.WriteLine ($"Observed DidConnectNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

適用対象