• 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: NSNumberFormatter question - showing mixed state
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumberFormatter question - showing mixed state


  • Subject: Re: NSNumberFormatter question - showing mixed state
  • From: Graham Cox <email@hidden>
  • Date: Sat, 23 Jan 2010 12:02:28 +1100

On 23/01/2010, at 2:19 AM, email@hidden wrote:

> I see the same behaviour when subclassing NSNumberFormatter.
> - (NSString *)stringForObjectValue:(id)anObject always receives an NSNumber.
>
> If you subclass NSFormatter directly then you can probably gain the control you need and detect the underlying object type.
>
> http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/DataFormatting/Articles/CreatingACustomFormatter.html


Ah, thanks - that was the push in the right direction I needed. Turns out if I override:

- (NSAttributedString *) attributedStringForObjectValue:(id) anObject withDefaultAttributes:(NSDictionary*) attributes;

then <anObject> is a string if it has been explicitly set as a string, so I can detect that and return it instead of converting it to a number. It doesn't get nil if I set nil, that is converted to a number = 0 earlier it seems. But this is good enough - I can set a string for the mixed value.

thanks!

--Graham


_______________________________________________

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: 
 >NSNumberFormatter question - showing mixed state (From: Graham Cox <email@hidden>)
 >Re: NSNumberFormatter question - showing mixed state (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: rightMouseDown not working as documented?
  • Next by Date: Re: rightMouseDown not working as documented?
  • Previous by thread: Re: NSNumberFormatter question - showing mixed state
  • Next by thread: Performance of NSArrayController update with Display Pattern bindings
  • Index(es):
    • Date
    • Thread