• 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 - necessary to manually inform of updates?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bindings - necessary to manually inform of updates?


  • Subject: Bindings - necessary to manually inform of updates?
  • From: Ken Tozier <email@hidden>
  • Date: Sun, 10 Apr 2005 05:37:26 -0400

Sorry for the repeat question, but I've been battling bindings all night and just can't get them working. I'm sure it's something simple but for the life of me I can't figure out what it is.

I created a simple project for the sole purpose of getting a test field in a window to update in response to events that change one variable in a controller. The update just isn't registering.

the controller class for the secondary nib is defined like so:

@interface Controller : NSObject
{
NSString *fileName;
}

- (void) setFileName:(NSString *) inString;
@end

It's implementation is this:

@implementation Controller

- (id) init
{
self = [super init];


return self;
}

- (void) setFileName:(NSString *) inString
{
[inString retain];
[fileName release];


fileName = inString;
}

@end

The interface for the app controller in the main nib is this:

@interface AppController : NSObject
{
}
@end

And the implementation is this:

@implementation AppController

- (id) init
{
self = [super init];
if (self)
{
NSWindowController *window = [[NSWindowController alloc] initWithWindowNibName: @"test_window"];
Controller *controller = [[Controller alloc] init];
int i,j;


[window showWindow: self];


for (i = 0; i < 10; i++)
{
NSString *tempName = [@"file " stringByAppendingPathComponent: [[NSNumber numberWithInt: i] stringValue]];


[controller setFileName: tempName];


NSLog(@"file name: %@", tempName);


for (j = 0; j < 100000000; j++); // delay loop for testing
}
}


return self;
}

@end

The connections and bindings are so simple I don't think they're wrong but here's a description.

The secondary nib contains an instantiated "Controller" object in the instances pane.
The "content" outlet of the NSObjectController is connected to the Controller object.
The text field in the secondary window is bound to the "fileName" field of the NSObjectController like so:
Bind to: NSObjectController
Controller Key: selection
Model Key Path: fileName
It's a non editable field so all of the value transformer fields are unchecked. (checking various ones didn't do anything anyway)

And that's basically it. When I launch the application the secondary window appears but the text field is initially blank and remains blank.

Anyone see the problem? Is there some method I can use to inform the bindings system that yes, this variable has changed dang it so inform the observers.

Thanks for any assistance. I'm totally stumped.

Ken

P.S. On a related note, are there any bindings debugging utilities out there? What I mean, is are there any utilities that expose everything the bindings interface is doing behind the scenes? As it stands now, there appears to be no systematic way to solve bindings problems. You just have to willy nilly check different settings and hope something will work. There is no runtime information about where or why a binding isn't working and this is rather frustrating.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Bindings - necessary to manually inform of updates?
      • From: Jonathon Mah <email@hidden>
  • Prev by Date: Re: scrolling an NSImageView leaves tracks
  • Next by Date: Re: Bindings - necessary to manually inform of updates?
  • Previous by thread: Rotating an NSImage
  • Next by thread: Re: Bindings - necessary to manually inform of updates?
  • Index(es):
    • Date
    • Thread