• 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: Loop between observers with KVO from UIScrollView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loop between observers with KVO from UIScrollView


  • Subject: Re: Loop between observers with KVO from UIScrollView
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 19 Jun 2011 22:58:11 -0700

On Jun 19, 2011, at 11:59, Tales Pinheiro de Andrade wrote:

>    if ([keyPath isEqualToString:@"contentOffset"]) {
>        CGPoint newContentOffset = [(UIScrollView *)object contentOffset];
>        newContentOffset.y = self.contentOffset.y;
>        self.contentOffset = newContentOffset;
>    }

It may be as simple as changing the above pattern to this pattern:

>    if ([keyPath isEqualToString:@"contentOffset"]) {
>        CGPoint newContentOffset = [(UIScrollView *)object contentOffset];
>        newContentOffset.y = self.contentOffset.y;
>        if (!CGPointEqualToPoint (self.contentOffset, newContentOffset))
>            self.contentOffset = newContentOffset;
>    }


But note:

1. You should really check the object (at least its class) as well as the keyPath.

2. You should really use a context parameter that's unique for your observations, and call super if the context isn't what you expect.


_______________________________________________

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: 
 >Loop between observers with KVO from UIScrollView (From: Tales Pinheiro de Andrade <email@hidden>)

  • Prev by Date: Re: Weird behavior of -URLByAppendingPathComponent:
  • Next by Date: NSArrayController loses selection upon CoreData refreshObject.
  • Previous by thread: Loop between observers with KVO from UIScrollView
  • Next by thread: Re: Loop between observers with KVO from UIScrollView
  • Index(es):
    • Date
    • Thread