Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 9, 2012, 01:06 AM   #1
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Bind NSOutlineView & NSTextView to NSTreeController?

Hi, I'm trying to do something similar to this:

http://www.raywenderlich.com/21752/h...a-in-a-mac-app

Except I have an NSOutlineView instead of an NSTableView.

The part I get stuck at is binding the NSTextField to my NSTreeController's selection.name. When I try running, I get this error:

Code:
[<NSOutlineView 0x10107d5d0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key name.
The thing that seems really odd to me is that it says NSOutlineView is the class it's trying to check at, rather than NSTreeController which seems like it would make a lot more sense... it is set to be bound to Tree Controller.

If I just uncheck this single binding, my whole app runs fine, so I'm pretty sure this is the cause. If I bind the column to arrangedObjects.name, that works fine. So why not selection.name for the text field?

I'm including a zipped file with my whole project so everyone can look at it and hopefully someone can tell me what I'm doing wrong. I haven't gotten far in the project so there's not much to look at. I think the only file of true interest is ShapeyrDocument.xib, although ShapeyrDocument.xcdatamodeId or ShapeyrOutlineViewController.m might be worth looking in...

Here's my full stack:

Code:
(
	0   CoreFoundation                      0x00007fff8b4f20a6 __exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff8fd993f0 objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8b586229 -[NSException raise] + 9
	3   Foundation                          0x00007fff8bcea1ec -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 238
	4   Foundation                          0x00007fff8bc31f59 -[NSObject(NSKeyValueCoding) valueForKey:] + 400
	5   Foundation                          0x00007fff8bc52808 -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 341
	6   AppKit                              0x00007fff8911c06c -[NSTreeController _singleValueForKeyPath:] + 162
	7   Foundation                          0x00007fff8bc527cf -[NSObject(NSKeyValueCoding) valueForKeyPath:] + 284
	8   AppKit                              0x00007fff89113184 -[NSBinder valueForBinding:resolveMarkersToPlaceholders:] + 163
	9   AppKit                              0x00007fff89115ad7 -[NSValueBinder _adjustObject:mode:observedController:observedKeyPath:context:editableState:adjustState:] + 667
	10  AppKit                              0x00007fff8911572c -[NSValueBinder _observeValueForKeyPath:ofObject:context:] + 192
	11  AppKit                              0x00007fff8911a18b -[NSTextValueBinder _observeValueForKeyPath:ofObject:context:] + 43
	12  AppKit                              0x00007fff8910a779 -[NSObject(NSKeyValueBindingCreation) bind:toObject:withKeyPath:options:] + 641
	13  AppKit                              0x00007fff88f9317a -[NSIBObjectData nibInstantiateWithOwner:topLevelObjects:] + 1012
	14  AppKit                              0x00007fff88f721fd loadNib + 317
	15  AppKit                              0x00007fff88f71729 +[NSBundle(NSNibLoading) _loadNibFile:nameTable:withZone:ownerBundle:] + 219
	16  AppKit                              0x00007fff890c468c +[NSBundle(NSNibLoading) loadNibFile:externalNameTable:withZone:] + 140
	17  AppKit                              0x00007fff890f76bb -[NSWindowController loadWindow] + 199
	18  AppKit                              0x00007fff890f7395 -[NSWindowController window] + 77
	19  AppKit                              0x00007fff89703721 -[NSDocument(NSPersistentUISupport) restoreDocumentWindowWithIdentifier:state:completionHandler:] + 179
	20  AppKit                              0x00007fff8930edce -[NSDocumentControllerPersistentRestoration loadedDocument:forAutoID:] + 179
	21  AppKit                              0x00007fff89314775 __block_global_22 + 254
	22  AppKit                              0x00007fff893143a3 __block_global_19 + 265
	23  AppKit                              0x00007fff8931428a __block_global_18 + 688
	24  AppKit                              0x00007fff89311e2a -[NSDocumentController _openDocumentWithContentsOfURL:usingProcedure:] + 593
	25  AppKit                              0x00007fff89313fcf __block_global_17 + 251
	26  libdispatch.dylib                   0x00007fff8c1f6f01 _dispatch_call_block_and_release + 15
	27  libdispatch.dylib                   0x00007fff8c1f30b6 _dispatch_client_callout + 8
	28  libdispatch.dylib                   0x00007fff8c1f80c8 _dispatch_main_queue_callback_4CF + 275
	29  CoreFoundation                      0x00007fff8b4940fe __CFRunLoopRun + 1614
	30  CoreFoundation                      0x00007fff8b4936b2 CFRunLoopRunSpecific + 290
	31  HIToolbox                           0x00007fff873450a4 RunCurrentEventLoopInMode + 209
	32  HIToolbox                           0x00007fff87344e42 ReceiveNextEventCommon + 356
	33  HIToolbox                           0x00007fff87344cd3 BlockUntilNextEventMatchingListInMode + 62
	34  AppKit                              0x00007fff88fd2613 _DPSNextEvent + 685
	35  AppKit                              0x00007fff88fd1ed2 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
	36  AppKit                              0x00007fff88fc9283 -[NSApplication run] + 517
	37  AppKit                              0x00007fff88f6dcb6 NSApplicationMain + 869
	38  Shapeyr                             0x0000000100001182 main + 34
	39  libdyld.dylib                       0x00007fff8808a7e1 start + 0
)
Attached Files
File Type: zip Shapeyr.zip (61.7 KB, 25 views)
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Dec 9, 2012, 04:01 AM   #2
jeanlain
macrumors 6502
 
Join Date: Mar 2009
I found the error. You connected your tree controllers' content outlet to the outline view. That doesn't make sense since the content of your tree controller should be a collection of objects, not a view. So when the text field asks for the controller's selection, a message is sent to the outline view.

Remove the connection (not the binding between the view and the controller) and it will work fine. You controller is already bound to the managed object context so you don't need to connect its content outlet.
jeanlain is offline   0 Reply With Quote
Old Dec 9, 2012, 09:27 AM   #3
ArtOfWarfare
Thread Starter
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
Quote:
Originally Posted by jeanlain View Post
I found the error. You connected your tree controllers' content outlet to the outline view. That doesn't make sense since the content of your tree controller should be a collection of objects, not a view. So when the text field asks for the controller's selection, a message is sent to the outline view.

Remove the connection (not the binding between the view and the controller) and it will work fine. You controller is already bound to the managed object context so you don't need to connect its content outlet.
Thank you so much!

How did you manage to find that? I'm wondering what questions you asked that I should have but didn't while trying to resolve this. I got as far as "Why the heck is it an NSOutlineView that's checking for the key?" - but I kept checking and double checking my Tree Controller's class and my Outline View's class and all of their bindings, it never occured to me that Outlets might trump Bindings in some cases, given it seems like in the docs they mostly say "This method does nothing if bindings are set..."
__________________
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
ArtOfWarfare is offline   0 Reply With Quote
Old Dec 9, 2012, 11:25 AM   #4
jeanlain
macrumors 6502
 
Join Date: Mar 2009
Quote:
Originally Posted by ArtOfWarfare View Post
Thank you so much!

How did you manage to find that? I'm wondering what questions you asked that I should have but didn't while trying to resolve this. I got as far as "Why the heck is it an NSOutlineView that's checking for the key?" - but I kept checking and double checking my Tree Controller's class and my Outline View's class and all of their bindings, it never occured to me that Outlets might trump Bindings in some cases, given it seems like in the docs they mostly say "This method does nothing if bindings are set..."
Since somehow a message was sent to the outline view (instead of the controller's selection) and bindings appeared correct, I looked at all the connections from/to the tree controller and saw the culprit.
jeanlain is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
changing NSTextView string value abcdefg12345 Mac Programming 4 Feb 5, 2014 06:50 AM
Allow NSOutlineView to be rearranged? ArtOfWarfare Mac Programming 2 Dec 5, 2012 10:48 PM
Issue with NSOutlineView? jaquadro Mac Programming 0 Nov 4, 2012 04:12 PM
NSOutlineView objects being released perrien Mac Programming 3 Aug 28, 2012 06:47 AM
Lion client auth bind 10.6.8 server not responding after successful bind Ccarroll Mac OS X 10.7 Lion 0 Jul 25, 2012 09:15 PM

Forum Jump

All times are GMT -5. The time now is 04:57 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC