• 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: Editing a dictionary using NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Editing a dictionary using NSTableView


  • Subject: Re: Editing a dictionary using NSTableView
  • From: Jason Coco <email@hidden>
  • Date: Sun, 26 Oct 2008 18:41:13 -0400


On Oct 26, 2008, at 18:29 , Graham Cox wrote:

Let's say I have a NS(Mutable)Dictionary and I'd like to make a very simple editor for its keys and values. So I have a NSTableView with two columns, key and value. The dictionary can contain any mix of strings and numbers, and the numbers can be ints or reals.

I find that when setting an edited value for a given key, everything gets converted to a string, because the object type returned by the table is a string. (The column type for value is a string, but numbers passed as the object value are automatically converted. I'm not using a formatter.)

Is there a simple way to allow the table to edit a value but preserve its type in the dictionary? I could check the type of the key I'm about to set and convert each value to that type, but it seems very clunky. I feel I've missed something obvious.

If I were doing it, I'd have a type key and let the user specify what type s/he wanted, like in the current property list editor. That way if the user wants to type a real number
but actually wants it to be a string for whatever reason, it could be. In my experience, whenever you want to mix strings and various number values, it's easiest to ask the
user what s/he's expecting to store rather than trying to guess.


J

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: Editing a dictionary using NSTableView
      • From: Graham Cox <email@hidden>
References: 
 >Editing a dictionary using NSTableView (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Newbie: Referencing Objects
  • Next by Date: Getting Styluses/Track Pad Input in Cocoa
  • Previous by thread: Editing a dictionary using NSTableView
  • Next by thread: Re: Editing a dictionary using NSTableView
  • Index(es):
    • Date
    • Thread