Cocoa-Java: NSArrayController and takeValueForKey
Cocoa-Java: NSArrayController and takeValueForKey
- Subject: Cocoa-Java: NSArrayController and takeValueForKey
- From: email@hidden
- Date: Mon, 3 Apr 2006 18:39:02 +0200 (CEST)
- Importance: Normal
Hello everybody,
I use an ArrayController to manage an array of Dictionary-objects (the
array-controller's contentArray is itself bound to UserDefaultsController
btw); each dictionary contains (among others) a "file"-key.
Furthermore I bound a text-field to "selection.file [arrController]"), so
that I can edit the corresponding value. It works like a charm if I type a
value directly in the text-field,
but now I want to set it programmatically to the filename returned by a
NSOpenPanel. Here is what I wrote (using Java):
...
NSArray filesToOpen = openPanel.filenames();
String fileName = (String)filesToOpen.objectAtIndex(0);
NSKeyValue.takeValueForKeyPath(arrController, fileName, "selection.file");
...
And here is the result:
NSUnknownKeyException: [<_NSControllerObjectProxy 0x3f51b0>
takeValue:forKey:]: attempt to assign value to unknown key: 'file'.
This class does not have an instance variable of the name file or _file,
nor a method of the name setFile, or _setFile
I also tried a couple of other variations:
((NSObject)arrController.selection()).takeValueForKey(fileName,"file");
and
((NSObject)arrController.valueForKey("selection")).takeValueForKey(fileName,"file")
with the same results. Finally I tried to do the same with Objective-C (in
a newly created test-project):
[arrController setValue:fileName forKeyPath:@"selection.file"];
and it worked perfectly! But I've already written _a lot_ of code in java
and don't want to port everything to ObjC (did I mention that I like java
_much_ better?).
Did anyone run into the same problem? Does anyone have an idea how to
solve this issue?
Thanks in advance and best regards,
Markus
_______________________________________________
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