• 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
Re: KVC with bindings to array elements?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVC with bindings to array elements?


  • Subject: Re: KVC with bindings to array elements?
  • From: Hank Heijink <email@hidden>
  • Date: Fri, 20 Oct 2006 14:28:51 -0400

I can't tell from this description. Can you expand a bit more? How exactly is the binding set up? What type of control, what key path, etc.? Can you post the code for your class?

Hank

On Oct 20, 2006, at 2:21 PM, Jeff Koftinoff wrote:


On 20-Oct-06, at 10:34 AM, Hank Heijink wrote:

Cocoa is right - you can't convert an NSArray to an NSDictionary just like that. Do you mean that you absolutely *have* to use an array? If so, the dictionary idea isn't going to work.


No, I do not have to use an NSArray... The NSDictionary can work just fine for me..


What I meant was something like this: in your object, have an instance variable like this:

NSDictionary *someDictionary;

The stuff that you want to bind your UI controls to would be in there, so that

[someDictionary valueForKey:@"someKey"]

will give you the value you want to have in the control. Then you bind the control to someDictionary.someKey, and that should do it.


I did that - Created a dictionary.

My class has the intance variable:

  NSDictionary *myFader;

I create it and initialize it with dummy data. Each item in the dictionary is an object with a float 'value'.

In my object I can do:

NSLog( @"Value for key 1: %@", [ myFader valueForKeyPath: @"1.value" ] );

And it does print out:

2006-10-20 11:16:39.301 MacTest[3968] Value for key 1: 1

But then the nib file loads

(gdb) continue
2006-10-20 11:16:39.439 MacTest[3710] An uncaught exception was raised
2006-10-20 11:16:39.453 MacTest[3710] Cannot create NSArray from object {
0 = < MyFader: 0x37b1c0>;
1 = < MyFader: 0x37b290>;
10 = < MyFader: 0x37b370>;
.... etc..
} of class NSCFDictionary


What am I doing wrong?

Thanks in advance

jeff


Hank

On Oct 20, 2006, at 1:20 PM, Jeff Koftinoff wrote:

Thank you for your response; But I still have a problem. I can't just have my accessor method return an NSDictionary - Cocoa expects it to be an NSArray, and I get an exception saying it can't convert the NSDictionary to the NSArray. I also tried implementing a method named:

	valueIn<Key>WithName

But it does not get called.

Jeff




Hank Heijink www.hankheijink.com email@hidden


_______________________________________________ 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: KVC with bindings to array elements?
      • From: Jeff Koftinoff <email@hidden>
References: 
 >KVC with bindings to array elements? (From: Jeff Koftinoff <email@hidden>)
 >Re: KVC with bindings to array elements? (From: Hank Heijink <email@hidden>)
 >Re: KVC with bindings to array elements? (From: Jeff Koftinoff <email@hidden>)
 >Re: KVC with bindings to array elements? (From: Hank Heijink <email@hidden>)
 >Re: KVC with bindings to array elements? (From: Jeff Koftinoff <email@hidden>)

  • Prev by Date: RE: encrypting a pdf
  • Next by Date: Re: Over-released Paragraph Style - Driving Me NUTS!
  • Previous by thread: Re: KVC with bindings to array elements?
  • Next by thread: Re: KVC with bindings to array elements?
  • Index(es):
    • Date
    • Thread