• 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: Binding (KVC/KVO) for C struct datatypes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding (KVC/KVO) for C struct datatypes


  • Subject: Re: Binding (KVC/KVO) for C struct datatypes
  • From: Dominik Pich <email@hidden>
  • Date: Thu, 4 Oct 2007 16:35:41 +0200

NSObjects are required. Wrap your struct in an NSValue
On 04.10.2007, at 15:12, Rudolph van der Merwe wrote:

I'm trying to create the following programatic binding:

[view bind:@"frame.size.width" toObject:self withKeyPath:@"width" options:nil];

Both view and width are instance variables in my controller object declared as:

NSImageView * view;
float width;

In other words, I'm trying to bind the frame width of the NSImageView
to a float ivar in my object.

This doesn't seem to work: I get the following runtime error:

An uncaught exception was raised
[<NSConcreteValue 0x145a60> valueForUndefinedKey:]: this class is not
key value coding-compliant for the key size.
*** Terminating app due to uncaught exception 'NSUnknownKeyException',
reason: '[<NSConcreteValue 0x145a60> valueForUndefinedKey:]: this
class is not key value coding-compliant for the key size.'

It seems the problem here is that [view frame] returns a NSRect
C-struct which has a size field which itself is a NSSize C-struct,
which has a float field 'width'. I was hoping that KVC can parse [view
frame].size.width using the @"frame.size.width" key-path. This doesn't
seem to be the case.

How does one implement bindings (or general KVC/KVO) for C-structs ?
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >Binding (KVC/KVO) for C struct datatypes (From: "Rudolph van der Merwe" <email@hidden>)

  • Prev by Date: Re: creating classes on the fly ??
  • Next by Date: Question about NSURLRequest
  • Previous by thread: Binding (KVC/KVO) for C struct datatypes
  • Next by thread: Re: Binding (KVC/KVO) for C struct datatypes
  • Index(es):
    • Date
    • Thread