Re: Custom NSView subclass - expressing the fact that a property affects the displayed image
Re: Custom NSView subclass - expressing the fact that a property affects the displayed image
- Subject: Re: Custom NSView subclass - expressing the fact that a property affects the displayed image
- From: Jerry Krinock <email@hidden>
- Date: Sat, 23 May 2015 14:49:57 -0700
> On 2015 May 23, at 07:10, Marek Hrušovský <email@hidden> wrote:
>
> Haven't read all the thread but i would use a custom property with overridden setter to call setNeedsDisplay with combination of keyPathsForValuesAffectingValueForKey: I think you can get rid of the glue code.
Yes, but you don’t need an overridden setter. Amy Worral explains it here:
http://stackoverflow.com/questions/6354368/how-to-observe-change-in-nsobject-properties
My interpretation is to declare a phantom property such as
@property NSInteger lookMaStuffChanged ;
then,
+ (NSSet*)keyPathsForValuesAffectingValueForLookMaStuffChanged {
return [NSSet alloc] initWithObjects:
@“whatever1”,
@“whatever2”,
…
nil] ;
}
Finally, observe lookMaStuffChanged with KVO.
In fact, the phantom property lookMaStuffChanged is never affected by anything; it’s never even set to anything.
Works for me.
_______________________________________________
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