• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bindings on Custom View (Initial Value)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bindings on Custom View (Initial Value)


  • Subject: Bindings on Custom View (Initial Value)
  • From: Stefan Arentz <email@hidden>
  • Date: Fri, 20 Jun 2008 23:51:27 -0400


With help from mmalc's binding examples I pretty much got the bindings on my custom view working.


I uploaded the app to:

 http://kip.sateh.com/BindableGradientViewWithObjectController/
 http://kip.sateh.com/BindableGradientViewWithObjectController.zip

(First link is source, second is an archive that contains source +project+compiled app)

It's a pretty basic example .. there is a GradientView that takes two bindings, startingColor and endingColor. These are set with two Color Wells and everything is connected with an NSObjectController. Click a color well and select a color to see the gradient change.

The only thing that I am not sure about is that I need to have the following in my GradientView's bind: method:

- (void) bind: (NSString*) name toObject: (id) object withKeyPath: (NSString*) path
options: (NSDictionary*) options
{
// ... do the binding ...


// ??? Without this setValue the initial values are not passed to the view
[self setValue: [object valueForKeyPath: path] forKey: name];


    // Refresh the view
    [self setNeedsDisplay: YES];
}

The binding examples from mmalc are not doing the setValue but without it my view keeps it's default colors instead of the colors that I am explicitely setting in my controller. The Color Wells are picking up this color.

I'm binding the GradientView with:

- (void) awakeFromNib
{
[gradientView bind: @"startingColor" toObject: objectController withKeyPath: @"selection.startingColor" options:
[NSDictionary dictionaryWithObject: [NSNumber numberWithBool:YES]
forKey: @"NSContinuouslyUpdatesValue"]];


[gradientView bind: @"endingColor" toObject: objectController withKeyPath: @"selection.endingColor" options:
[NSDictionary dictionaryWithObject: [NSNumber numberWithBool:YES]
forKey: @"NSContinuouslyUpdatesValue"]];
}


Is there maybe an option that I need to set to force an initial update?

 S.

_______________________________________________

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


  • Prev by Date: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
  • Next by Date: Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
  • Previous by thread: Re: Fundamental mistake in my understanding of use of classes/instances/encapsulation/messaging
  • Next by thread: Bindings Concept Question
  • Index(es):
    • Date
    • Thread