• 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 NSTextField to an array
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Binding NSTextField to an array


  • Subject: Re: Binding NSTextField to an array
  • From: Jeremy Hughes <email@hidden>
  • Date: Mon, 06 Mar 2017 19:31:46 +0000

> On 6 Mar 2017, at 17:34, Jeremy Hughes <email@hidden> wrote:
>
> It all works now.

Actually, it works as far as the text field displays “Multiple” (placeholder) for multiple values, but it doesn’t work when I set a value in the text field. In that case I get:

Error setting value for key path selection.self of object <NSArrayController: 0x6080001c22b0>[object class: NSMutableDictionary, number of selected objects: 2] (from bound object <NSTextField: 0x6080001e2500>): [<__NSCFNumber 0x337> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key self.

The text field is bound to an array of NSNumbers via an array controller (using a Swift array that is marked as “dynamic”)

I can get around this by writing a “Number” wrapper:

	class Number: NSObject
	{
		dynamic var value: NSNumber

		init(_ value: Int) { self.value = NSNumber(value: value) }
	}

	dynamic var values: [Number]

and binding the text field to the “value” field of this wrapper (so the controller key is arrayController.selection and the model key path is “value").

But I wonder if it is possible to bind directly to an array of NSNumbers without using a wrapper.

I’ve tried doing that using an array of NSNumbers with the model key path set to “value” (i.e. the value of the NSNumber) but I get the following error:

 [<__NSCFNumber 0x337> valueForUndefinedKey:]: this class is not key value coding-compliant for the key value.

So, unless there’s another key path I can use for NSNumber, I’m guessing it isn’t possible to do this.

Jeremy


_______________________________________________

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


  • Follow-Ups:
    • Re: Binding NSTextField to an array
      • From: Quincey Morris <email@hidden>
References: 
 >Binding NSTextField to an array (From: Jeremy Hughes <email@hidden>)
 >Re: Binding NSTextField to an array (From: Mike Abdullah <email@hidden>)
 >Re: Binding NSTextField to an array (From: Jeremy Hughes <email@hidden>)
 >Re: Binding NSTextField to an array (From: Jonathan Mitchell <email@hidden>)
 >Re: Binding NSTextField to an array (From: Jeremy Hughes <email@hidden>)
 >Re: Binding NSTextField to an array (From: Mike Abdullah <email@hidden>)
 >Re: Binding NSTextField to an array (From: Jeremy Hughes <email@hidden>)

  • Prev by Date: Re: Unicode filenames with Apple File System and UIManagedDocument
  • Next by Date: ncurses type wrapper for NStextview
  • Previous by thread: Re: Binding NSTextField to an array
  • Next by thread: Re: Binding NSTextField to an array
  • Index(es):
    • Date
    • Thread