Re: Best way to bind an Inspector to iVars/Properties?
Re: Best way to bind an Inspector to iVars/Properties?
- Subject: Re: Best way to bind an Inspector to iVars/Properties?
- From: Gordon Apple <email@hidden>
- Date: Sat, 08 Dec 2007 16:33:34 -0600
I'm not quite sure what you mean about KVO wrapping them in NSValues.
I'm currently taking the approach of leaving most stuff in my props
dictionary and adding a lot of properties declarations, mostly with custom
implementations. At least it seems to work for the parameters I have bound
so far. Some of them are more complex than I would like, and it looks like
I will also need a significant number of enabler-binding properties.
I would like to keep my Shape class as a fairly clean data-model object.
However, I haven't yet figured out a good way to do that other than possibly
putting all these properties in a category. I currently use a subclass of
NSArrayController to handle shape selection. It is bound to my shapelist
(i.e., drawlist). Ideally, I would like to interject something like an
object controller between the bound shapelist and its component shapes and
place all the properties complexity there. Is there currently any way to do
something like this? Maybe a statically defined Shape delegate which (as
shown in Hillegass) routes all unimplemented methods to the delegate?
The Shape props dictionary is intended to be very flexible, which is why
I prefer to avoid ivars. I'm trying to figure out an architecture that
would easily allow later addition of new properties such as new media types,
animation, connections, actions, etc.
> Howdy!
>
> I think option 9 is the best:
>
> 9. Just use NSRect as the ivar.
>
> Example code:
>
> @interface MyController : NSObject {
> NSRect test;
> }
>
> @property NSRect test;
>
> @end
>
>
> @implementation MyController
>
> @synthesize test;
>
> - (void)awakeFromNib {
> [self addObserver:self forKeyPath:@"test"
> options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld
> context:nil];
> self.test = NSMakeRect(2, 3, 4, 2);
> self.test = NSMakeRect(2, 1, 4, 2);
> }
>
> - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
> change:(NSDictionary *)change context:(void *)context
> {
> NSLog(@"changed %@, %@", object, change);
> }
>
> @end
>
> KVO will wrap them in NSValue's for you.
>
> corbin
>
_______________________________________________
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