• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bindings & Reverting Properties
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings & Reverting Properties


  • Subject: Re: Bindings & Reverting Properties
  • From: Dave Keck <email@hidden>
  • Date: Sun, 23 Aug 2009 15:54:54 -1000

For the archives...

The cleanest way I've found to get around my problem is best illustrated
with some example code:

=========================

- (void)setHappy: (BOOL)newHappy
{
   BOOL oldHappy = happy;

   happy = newHappy;

   if (![self save])
   {       // Do the revert now
       happy = oldHappy;

       // Update the UI later
       [self performSelector: @selector(updateUI)
                  withObject: nil
                  afterDelay: 0.0];
   }
}

- (void)updateUI
{
   [self willChangeValueForKey: @"happy"];
   [self didChangeValueForKey: @"happy"];
}

=========================

In the above example, I do the actual revert in the current iteration of the
run loop, and save the updating of the UI for the next iteration. I also
thought about scheduling the entire revert task for the next iteration, but
found this wasn't as good an option. The reason it's not as good is because
before the revert happens, the preferences will temporarily reflect a state
that hasn't (and won't) be saved to disk. So if someone asks for the value
of happy during the _current_ iteration of the run loop, it will erroneously
return the temporary value before the revert happens. Therefore, it's a
better idea to simply do the revert now, and update the UI later.

Perhaps someone, somewhere will find that information useful.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Bindings & Reverting Properties (From: Dave Keck <email@hidden>)
 >Re: Bindings & Reverting Properties (From: Quincey Morris <email@hidden>)
 >Re: Bindings & Reverting Properties (From: Dave Keck <email@hidden>)
 >Re: Bindings & Reverting Properties (From: Quincey Morris <email@hidden>)
 >Re: Bindings & Reverting Properties (From: Dave Keck <email@hidden>)

  • Prev by Date: Re: Core Animation + Garbage Collection
  • Next by Date: Re: Core Animation + Garbage Collection
  • Previous by thread: Re: Bindings & Reverting Properties
  • Next by thread: Setting multi line Text to Radio button
  • Index(es):
    • Date
    • Thread