Thank you for the answer. It just worked! About the notes:
1.: should I just check if the object is different from self? Or some more "complicated"? And what should I check as keyPath? 2.: if I send a context parameter from observer (the context can be a NSString for example, right?), should I chech if the string is expected? And I only should call super if the context is invalid? Reading Apple documentation I saw that I should ever call super, but when I did it, the app crashed (I did not went look what was wrong. Should I or it's not really necessary?) Sorry, but I'm pretty new with KVO. I'm just read the KVO quick star guide and KVO programming guide. Em 20/06/2011, às 02:58, Quincey Morris escreveu: 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