• 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 in Panther
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSNumberFormatter in Panther


  • Subject: Re: NSNumberFormatter in Panther
  • From: Chaz McGarvey <email@hidden>
  • Date: Sun, 14 Dec 2003 17:09:26 -0700

Thanks for getting back to me. I've posted a few questions about formatters before but people generally don't seem to want to talk about them.

On Dec 14, 2003, at 1:46 AM, p3consulting wrote:

I also have found some problems with NSFormatter's under Panther,
investigation showed that the main difference is that the
- (BOOL)getObjectValue:(id *)anObject forString:(NSString *)string errorDescription:(NSString **)error
of the formatter is called on each key stroke when in Jaguar it was called at the end
(tab, enter, click ouside of the field, closing the window)

The error string parameter is nil until the formatter is called for an "end of editing" event.

Examples of formatters found in "Cocoa programming" by Anguish, Buck, Yacktman work because they do test the error parameter, (as per recommendation of the Apple documentation) but some examples from Vermont Recipes do now crashes under Panther.

However I don't have seen the problem you describe with the standard formatters clearing the whole field in case of errors.

Are you using built-in Cocoa formatters or formatters from a third party ?

I'm using the built-in formatter, specifically NSNumberFormatter (added using IB). I have done some more testing and now I'm more confused than ever. Before, I was using the formatter just make a text field accept integers with a minimum of 0 and a maximum of 255. I just tried doing a float formatter (default setting for a formatter added using IB) and the behavior is even more bizarre. Typing a period sets the text field to "0.00." Typing a single number key x sets the text field to "x.00." The next number key typed will do one of two things, depending on the number. Typing 0, 1, 2, 3, or 4 will do absolutely nothing. Typing 5, 6, 7, 8, or 9 will increment the text field by 0.01. For example, I type 7 and the text field is now "x.01." Type a 2 and the text field is still "x.01." Then type a 5 and the text field will be "x.02." Holding down a key 5-9 will continue incrementing the float (even incrementing x by 1 every 100 increments).

Also with the float formatter, the delete key does not delete unless the entire text field contents are selected. Otherwise, it just sets the text field back to the original "x.00." And as with the integer formatter, any letter key will completely clear tho text field.

Also FYI, formatters for me don't work in IB, and aren't they supposed to? I have to switch back to Xcode and run my program from there to get formatters to do anything at all. Or maybe that is the case? I thought I remember formatters working in IB in Jaguar, but I'm not sure of it.

I also am using the 10.2.8 SDK.

So that's what I know. I remember being able to add a formatter to a text field in Jaguar, set its options right there in IB and be done with it. But how annoying this has been. Weird.

On 13 dic. 2003, at 21:10, Chaz McGarvey wrote:

NSNumberFormatters don't seem to work in Panther like they did in Jaguar. In Jaguar when the user typed something the formatter couldn't accept, it would just not accept that into the field (and it probably beeped or something). In Panther I find that an attached formatter causes the text field to be cleared of all it's text when a wrong key is pressed. Other weird things include not being able to make a number negative (by pushing dash) until at least on character of the number is entered. And if a user tries to type a number that is too big (when a maximum is set), then the text field is cleared.

Is this really how it is supposed to work or is something wrong?

Chaz McGarvey
http://www.brokenzipper.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >NSNumberFormatter in Panther (From: Chaz McGarvey <email@hidden>)
 >Re: NSNumberFormatter in Panther (From: p3consulting <email@hidden>)

  • Prev by Date: Re: Intercepting JavaScript calls in WebViews
  • Next by Date: Re: Odd memory issue -- not a newbie
  • Previous by thread: Re: NSNumberFormatter in Panther
  • Next by thread: Random()
  • Index(es):
    • Date
    • Thread