Re: NSViewController Binding Problem continued
I haven't yet come across a situation in which it would be desirable for an NSTableView and its associated NSArrayController to be in separate nibs. I guess Apple haven't, either ;) Actually, I would think that it's quite common in apps that use NSViewController. Imagine a view managed by one view controller displaying a list of items in a table view. Then another view, managed by another view controller, displays details about the selected object using several text fields and maybe you can edit the selected object's attributes with sliders and pop up buttons. I'd want to use the same array controller as the data source for the views in the different nib files, so I'd keep it somewhere central, like the document or the window controller (in a non-doc based app) . I'd give the view controllers access to the array controller by setting their representedObject to either the array controller itself or the document/window controller that's keeping the array controller. Am I thinking about this in the wrong way? I guess that it would be nice if IB would let you bind directly to representedObject when the File's Owner's class is set to an NSViewController so that when the nib is loaded, the table view gets what it wants. Seems like a bit of a special case to me to circumvent something that Apple could just fix properly! Mind you, it might be nice not to have to type representedObject. in front of every binding in a view nib... Yeah, that's not a bad side effect :) Cathy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
On Sat, Jul 19, 2008 at 9:44 AM, Cathy Shive [EMAIL PROTECTED] wrote: [ Hamish wrote:] I haven't yet come across a situation in which it would be desirable for an NSTableView and its associated NSArrayController to be in separate nibs. I guess Apple haven't, either ;) Actually, I would think that it's quite common in apps that use NSViewController. Imagine a view managed by one view controller displaying a list of items in a table view. Then another view, managed by another view controller, displays details about the selected object using several text fields and maybe you can edit the selected object's attributes with sliders and pop up buttons. The app I'm currently developing is my first foray into NSViewControllers and I haven't done anything particularly complex, so take this with a pinch of salt. But for all the same reasons I would want to separate views into multiple nibs, I would want to separate controllers too. The design of my view hierarchy is subsequently informed by this consideration. So for what you describe, I would make the detail view a child of the master table view, rather than making them both children of some other view. This makes particular sense in my current development, where detail views change according to the selection in master views. But it would also feel strange to me to separate the table view from its array controller to such an extent as putting them in separate nibs. Maybe further experience will change my mind about this, though. As a workaround for what Ivy describes, I would try using an extra array controller serving as a proxy, with its contentObject bound to representedObject.self. (Whether it would fail, just like NSTableView, if not bound directly to an NSArrayController, I do not know.) Hamish ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
Hm. Sean, I don't seem to be getting anything in my debugger or in Console when I try to establish bindings in IB as I did before. Just silence.and not working. I'm wondering if at the very least the representedObject can be bound to in IB when it is a model object (not ObjectController or arrayController). Ivy Feraco UI Developer Message: 6 Date: Thu, 17 Jul 2008 12:26:18 -0400 From: Sean McBride [EMAIL PROTECTED] Subject: Re: NSViewController Binding Problem continued To: Ivy Feraco [EMAIL PROTECTED], cocoa-dev@lists.apple.com Message-ID: [EMAIL PROTECTED] Content-Type: text/plain; charset=ISO-8859-1 On 7/17/08 11:53 AM, Ivy Feraco said: There was a previous post back in April about a problem with binding to the representedObject in NSViewController. I missed that, but I am having problems binding via NSViewController's representedObject too. When instantiating the view controller, I set the represented object to an NSArrayController. I'm using NSObjectController. vc = [[MyViewController alloc] initWithNibName:@newView bundle:nil]; [vc setRepresentedObject:arrayController]; When setting the bindings in the nib file, I make the File's Owner MyViewController class, then try to bind columns of NSTableView to the File's Owner using a path like representedObject.arrangedObjects.displayText. This would not work, even though the array controller does contain data. Did not work how? In my case, when I attempt to bind a view's binding, IB fails to connect the binding and prints the following in Console: 2008-07-17 12:13:54 Interface Builder[9568] Ignoring exception related to working with bindings: NSUnknownKeyException, [NSCustomObject 0x1b8c0520 addObserver:MyCustomView 0x1b8c7490 forKeyPath:@representedObject.selection.subjectToBrainsightTransform options:0x0 context:0x7d3] was sent to an object that is not KVC- compliant for the representedObject property. Do you see something similar in Console? Now in my case, the view in question is my own custom NSView subclass, it exposes about a dozen bindings and they've been working for a very long time. I've only seen problems once I started using NSViewContoller. By connecting gdb to IB: (gdb) po 0x1b8c0520 NSCustomObject(MyViewController) 0x1b8c0520 Looks like some kind of IB object meant to stand in for my viewcontroller. A previous post brought up the exact same issue, and he worked around it by using the awakefromNib method to bind the table to the representedObject's arrangedObjects in code. I did something similar using the windowDidLoad method. I'll have to try that... -- Sean McBride, B. Eng [EMAIL PROTECTED] Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
On Thu, Jul 17, 2008 at 8:50 PM, Ron Lue-Sang [EMAIL PROTECTED] wrote: The tableview is expecting to be bound to the arraycontroller directly. It doesn't know that representedObject is an arrayController. You might wish to file an enhancement request for NSViewController to provide an init method taking a representedObject to be set up before attempting bindings etc., which would circumvent this issue. Or you could argue that, according to the principles of duck typing, NSTableView shouldn't care, just as long as representedObject.arrangedObjects.displayText quacks like an array. In which case it's a bug. Hamish ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
Hi Ivy, You can bind the representedObject in NIB, I do it all the time. My rO is an NSPersistentDocument subclass, which is set immediately after the view controller is -init-ed. The bindings in the nib are only set up after -loadView is called, which occurs after something in your app asks for the -view. So as long as the rO is not nil when -loadView is called then it should bind properly. Granted though I haven't tried it with an NSController subclass as the rO. Have you tried binding it in code during -awakeFromNib? Jonathan www.espresso-served-here.com smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
On Jul 17, 2008, at 10:26 PM, Hamish Allan wrote: You might wish to file an enhancement request for NSViewController to provide an init method taking a representedObject to be set up before attempting bindings etc., which would circumvent this issue. I wonder if it would actually make a difference in this case. Since the nib doesn't get loaded until the 'load view' method is called and she's setting the rO directly after the initializer (before requesting the view), the result would be the same, right? Either way, the object you're binding to is the view controller and not the array controller that the NSTableView requires. Or you could argue that, according to the principles of duck typing, NSTableView shouldn't care, just as long as representedObject.arrangedObjects.displayText quacks like an array. In which case it's a bug. Seems like this is the real issue ;) I'm really curious to find a solution to this, too - one that doesn't involve adding another array controller to the app or moving the bindings setup to code. Going to code isn't too bad, tho... I guess that it would be nice if IB would let you bind directly to representedObject when the File's Owner's class is set to an NSViewController so that when the nib is loaded, the table view gets what it wants. Just some wishful thinking. Best, Cathy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
Hi Ivy, Can you tell us what the bound object the table receives is? If you could call this method (which, in its current state, would go in an NSTableView subclass) somewhere: - (NSArrayController *)arrayController; { return [[[self tableColumnWithIdentifier:@myColumn] infoForBinding:NSValueBinding] valueForKey:NSObservedObjectKey]; } then print the results to the console. Calling it at the end of awakeFromNib: with a -performSelector:withObject:afterDelay: (not necessary but just to be sure!) should do the trick. Is what you get back an array controller? Jonathan www.espresso-served-here.com smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
On Fri, Jul 18, 2008 at 11:18 PM, Cathy Shive [EMAIL PROTECTED] wrote: I wonder if it would actually make a difference in this case. Since the nib doesn't get loaded until the 'load view' method is called Nor it does. and she's setting the rO directly after the initializer (before requesting the view), the result would be the same, right? Indeed. In the face of that, it's not clear to me why the tableview doesn't know that the representedObject is an arrayController, given that the bindings can't have been set up until after the nib is loaded. Either way, the object you're binding to is the view controller and not the array controller that the NSTableView requires. I'd definitely call that requirement a bug. Or you could argue that, according to the principles of duck typing, NSTableView shouldn't care, just as long as representedObject.arrangedObjects.displayText quacks like an array. In which case it's a bug. Seems like this is the real issue ;) I'm really curious to find a solution to this, too - one that doesn't involve adding another array controller to the app or moving the bindings setup to code. Going to code isn't too bad, tho... I haven't yet come across a situation in which it would be desirable for an NSTableView and its associated NSArrayController to be in separate nibs. I guess Apple haven't, either ;) I guess that it would be nice if IB would let you bind directly to representedObject when the File's Owner's class is set to an NSViewController so that when the nib is loaded, the table view gets what it wants. Seems like a bit of a special case to me to circumvent something that Apple could just fix properly! Mind you, it might be nice not to have to type representedObject. in front of every binding in a view nib... Hamish ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSViewController Binding Problem continued
There was a previous post back in April about a problem with binding to the representedObject in NSViewController. When instantiating the view controller, I set the represented object to an NSArrayController. vc = [[MyViewController alloc] initWithNibName:@newView bundle:nil]; [vc setRepresentedObject:arrayController]; When setting the bindings in the nib file, I make the File's Owner MyViewController class, then try to bind columns of NSTableView to the File's Owner using a path like representedObject.arrangedObjects.displayText. This would not work, even though the array controller does contain data. A previous post brought up the exact same issue, and he worked around it by using the awakefromNib method to bind the table to the representedObject's arrangedObjects in code. I did something similar using the windowDidLoad method. So I want to reopen the issue - Does anyone have any insight into why it doesn't work in IB? It seems like it should, and that this was an intended benefit of having a representedObject for the ViewController, and Apple's NSVIewController documentation seems to confirm this: Declaring a generic representedObject property, to make it easy to establish bindings in the nib to an object that isn't yet known at nib- loading time or readily available to the code that's doing the nib loading. so, is it a Cocoa bug? Thanks, Ivy Feraco UI Developer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSViewController Binding Problem continued
On Jul 17, 2008, at 8:53 AM, Ivy Feraco [EMAIL PROTECTED] wrote: There was a previous post back in April about a problem with binding to the representedObject in NSViewController. When instantiating the view controller, I set the represented object to an NSArrayController. vc = [[MyViewController alloc] initWithNibName:@newView bundle:nil]; [vc setRepresentedObject:arrayController]; When setting the bindings in the nib file, I make the File's Owner MyViewController class, then try to bind columns of NSTableView to the File's Owner using a path like representedObject.arrangedObjects.displayText. The tableview is expecting to be bound to the arraycontroller directly. It doesn't know that representedObject is an arrayController. Either put the arrayController as a top level object in the nib or create the binding in awakeFromNib using the arrayController as the toObject: argument and @arrangedObjects.columnPropertyName as the keypath. This would not work, even though the array controller does contain data. A previous post brought up the exact same issue, and he worked around it by using the awakefromNib method to bind the table to the representedObject's arrangedObjects in code. I did something similar using the windowDidLoad method. So I want to reopen the issue - Does anyone have any insight into why it doesn't work in IB? It seems like it should, and that this was an intended benefit of having a representedObject for the ViewController, and Apple's NSVIewController documentation seems to confirm this: Declaring a generic representedObject property, to make it easy to establish bindings in the nib to an object that isn't yet known at nib-loading time or readily available to the code that's doing the nib loading. so, is it a Cocoa bug? Thanks, Ivy Feraco UI Developer ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/luesang%40apple.com This email sent to [EMAIL PROTECTED] ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]