• 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: Mike Abdullah <email@hidden>
  • Date: Mon, 06 Mar 2017 14:16:37 +0100

From what I understand of your example, you’re not “binding” anything in a Cocoa sense.

What you is an NSArrayController. Bind your text field to the array controller. Supply the array controller with content, and have it derive the selected value, be it single or multiple.

> On 6 Mar 2017, at 14:10, Jeremy Hughes <email@hidden> wrote:
>
> Hi,
>
> This seems like an elementary question.
>
> I’d like to bind an NSTextField to an array of numerical values, so that the text field will either display a single value if the values are identical or will display a multiple values marker if the values are different.
>
> Using Swift, I can bind a text field to a single value like this:
>
> dynamic var value = NSNumber(value: 7)
>
> But if I try to bind to an array of values like this:
>
> dynamic var values = [NSNumber(value: 7), NSNumber(value: 3)]
>
> I get the following error:
>
> Cannot create number from object (
>    7,
>    3
> ) of class _TtGCs23_ContiguousArrayStorageCSo8NSNumber_
>
> How do I bind an NSTextField to an array?
>
> 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


_______________________________________________

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: Jeremy Hughes <email@hidden>
References: 
 >Binding NSTextField to an array (From: Jeremy Hughes <email@hidden>)

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