コード例 #1
0
            public static void NotifyWhenDeallocated(NSObject obj, Action deallocated)
            {
                // Add an associated object which will be 'released'd when the obj
                // to watch is deallocated. When 'release' is sent, then invoke
                // the 'deallocated' callback.
                var notifier = new ReleaseNotifier(deallocated);

                obj.SetAssociatedObject(IntPtr.Zero, notifier, AssociatedObjects.AssociationPolicy.Retain);
                notifier.Dispose();                  // remove any managed references.
                notifier.enabled = true;             // notify on the next 'release' message.
            }