MLModelCollection.DidChangeNotification Eigenschaft

Definition

Achtung

This property always returns null.

Diese Eigenschaft gibt immer zurück null.

[Foundation.Advice("Use MLModelCollection.Notifications.ObserveDidChange helper method instead.")]
[Foundation.Field("MLModelCollectionDidChangeNotification", "CoreML")]
public static Foundation.NSString DidChangeNotification { get; }
[System.Obsolete("This property always returns null.")]
public static Foundation.NSString? DidChangeNotification { get; }
[<Foundation.Advice("Use MLModelCollection.Notifications.ObserveDidChange helper method instead.")>]
[<Foundation.Field("MLModelCollectionDidChangeNotification", "CoreML")>]
static member DidChangeNotification : Foundation.NSString
[<System.Obsolete("This property always returns null.")>]
static member DidChangeNotification : Foundation.NSString

Eigenschaftswert

NSString Konstante, sollte als Token NSNotificationCenterfür .

Attribute

Hinweise

Diese Konstante kann zum NSNotificationCenter Registrieren eines Listeners für diese Benachrichtigung verwendet werden. Dies ist eine NSString Anstelle einer Zeichenfolge, da diese Werte in einigen nativen Bibliotheken als Token verwendet werden können, anstatt nur für ihren tatsächlichen Zeichenfolgeninhalt verwendet zu werden. Der Parameter "notification" für den Rückruf enthält zusätzliche Informationen, die für den Benachrichtigungstyp spezifisch sind.

Um diese Benachrichtigung zu abonnieren, können Entwickler die Komfort ObserveDidChange(NSObject, EventHandler<NSNotificationEventArgs>) - oder ObserveDidChange(EventHandler<NSNotificationEventArgs>) Methoden verwenden, die stark typierten Zugriff auf die Parameter der Benachrichtigung bieten.

Das folgende Beispiel zeigt, wie Sie die stark typierte MLModelCollection.Notifications Klasse verwenden, um die Vermutung der verfügbaren Eigenschaften in der Benachrichtigung zu entfernen:

//
// Lambda style
//

// listening
notification = MLModelCollection.Notifications.ObserveDidChange ((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, MLModelCollection.NSNotificationEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);
}

void Setup ()
{
    notification = MLModelCollection.Notifications.ObserveDidChange (Callback);
}

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

Das folgende Beispiel zeigt, wie Sie die Benachrichtigung mit der DefaultCenter-API verwenden:

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

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

void Setup ()
{
    NSNotificationCenter.DefaultCenter.AddObserver (MLModelCollection.DidChangeNotification, Callback);
}

Gilt für: