EAAccessoryManager.DidConnectNotification プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
DidConnect の通知定数
[Foundation.Advice("Use EAAccessoryManager.Notifications.ObserveDidConnect helper method instead.")]
[Foundation.Field("EAAccessoryDidConnectNotification", "ExternalAccessory")]
public static Foundation.NSString DidConnectNotification { get; }
member this.DidConnectNotification : Foundation.NSString
プロパティ値
NSString 定数は、NSNotificationCenter のトークンとして使用する必要があります。
- 属性
注釈
この定数を と共 NSNotificationCenter に使用して、この通知のリスナーを登録できます。 これらの値は、実際の文字列コンテンツに対して純粋に使用されるのではなく、一部のネイティブ ライブラリでトークンとして使用できるため、これは文字列ではなく NSString です。 コールバックの 'notification' パラメーターには、通知の種類に固有の追加情報が含まれています。
この通知をサブスクライブするために、開発者は便利 EAAccessoryManager.Notificationsな メソッド をObserveDidConnect 使用できます。このメソッドは、通知のパラメーターへの厳密に型指定されたアクセスを提供します。
次の例は、厳密に型指定された Notifications クラスを使用して、通知で使用可能なプロパティから推測を取り出す方法を示しています。
//
// 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 ();
}
次の例は、DefaultCenter API で通知を使用する方法を示しています。
// Lambda style
NSNotificationCenter.DefaultCenter.AddObserver (
EAAccessoryManager.DidConnectNotification, (notification) => {Console.WriteLine ("Received the notification EAAccessoryManager", notification); }
// Method style
void Callback (NSNotification notification)
{
Console.WriteLine ("Received a notification EAAccessoryManager", notification);
}
void Setup ()
{
NSNotificationCenter.DefaultCenter.AddObserver (EAAccessoryManager.DidConnectNotification, Callback);
}