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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to