• 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
Cocoa-Java: NSArrayController and takeValueForKey
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Moderator EOT (Re: "Yellow Box" resurrection. Should we hold our breath for it?)
  • Next by Date: Re: Path names in executable
  • Previous by thread: Re: Distro?
  • Next by thread: The drawer and sheets problem
  • Index(es):
    • Date
    • Thread