Share via


UIApplication.SignificantTimeChangeNotification プロパティ

定義

SignificantTimeChange の通知定数

[Foundation.Advice("Use UIApplication.Notifications.ObserveSignificantTimeChange helper method instead.")]
[Foundation.Field("UIApplicationSignificantTimeChangeNotification", "UIKit")]
public static Foundation.NSString SignificantTimeChangeNotification { get; }
member this.SignificantTimeChangeNotification : Foundation.NSString

プロパティ値

NSString 定数は、NSNotificationCenter のトークンとして使用する必要があります。

属性

注釈

この定数を と共 NSNotificationCenter に使用して、この通知のリスナーを登録できます。 これらの値は、実際の文字列コンテンツに対して純粋に使用されるのではなく、一部のネイティブ ライブラリでトークンとして使用できるため、これは文字列ではなく NSString です。 コールバックの 'notification' パラメーターには、通知の種類に固有の追加情報が含まれています。

この通知をサブスクライブする場合は、便利 UIApplication.Notificationsな を使用できます。M:UIKit.UIKit.UIApplication.Notifications.ObserveSignificantTimeChange* メソッドは、通知のパラメーターへの厳密に型指定されたアクセスを提供します。

次の例は、厳密に型指定された Notifications クラスを使用して、通知で使用可能なプロパティから推測を取り出す方法を示しています。

//
// Lambda style
//

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

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

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

void Setup ()
{
    notification = UIApplication.Notifications.ObserveSignificantTimeChange (Callback);
}

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

次の例は、DefaultCenter API で通知を使用する方法を示しています。

// Lambda style
NSNotificationCenter.DefaultCenter.AddObserver (
        UIApplication.SignificantTimeChangeNotification, (notification) => {Console.WriteLine ("Received the notification UIApplication", notification); }


// Method style
void Callback (NSNotification notification)
{
    Console.WriteLine ("Received a notification UIApplication", notification);
}

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (UIApplication.SignificantTimeChangeNotification, Callback);
}

適用対象