Confusion about KVC and custom setter
Confusion about KVC and custom setter
- Subject: Confusion about KVC and custom setter
- From: Rick Mann <email@hidden>
- Date: Mon, 09 Apr 2012 18:28:52 -0700
I'm observing a property of one of my classes, "selectedIndex". Even if the value is set to the same value, KVO fires and my observe method gets called, which is something I thought by default it doesn't do.
So I implemented a custom setter for my property, like this:
- (void)
setSelectedIndex: (NSUInteger) inIndex
{
if (mSelectedIndex == inIndex)
{
return;
}
[self willChangeValueForKey: @"selectedIndex"];
mSelectedIndex = inIndex;
[self didChangeValueForKey: @"selectedIndex"];
}
Sure enough, my method returns early, but KVO still gets called. What am I misunderstanding?
Thanks,
Rick
_______________________________________________
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