• 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
NSNumberFormattter not working
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSNumberFormattter not working


  • Subject: NSNumberFormattter not working
  • From: Ken Tozier <email@hidden>
  • Date: Thu, 12 Jul 2007 09:11:38 -0400

Hi

I have a programatically generated NSTextField subclass and am trying to set it's formatter in the subclass init method but it doesn't seem to work. I can enter any character (even alphabetic, punctuation etc) The text field is embedded in another custom view so I created the following setter method to make setting the format more direct

- (void) setFormatter:(id) inFormatter
{
	[textField setFormatter: inFormatter];
}


The actual formatter is set up as a static global in the text field container class like this


static NSNumberFormatter		*gNumberFormatter		= nil;

@implementation PMTokenView

+ (void) initialize
{
	gNumberFormatter		= [[NSNumberFormatter alloc] init];

	// constrain input to values between 1 and 1000
	[gNumberFormatter setMinimum: [NSNumber numberWithInt: 1]];
	[gNumberFormatter setMinimum: [NSNumber numberWithInt: 1000]];
}

- (id) initWithFrame:(NSRect) inRect
{
	self = [super initWithFrame: inRect];
	if (self)
	{
		[self setFormatter: gNumberFormatter];
	}

	return self;
}

@end

Anyone point out what I'm doing wrong?

Thanks for any help

Ken
_______________________________________________

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: NSNumberFormattter not working
      • From: Ken Tozier <email@hidden>
  • Prev by Date: Re: Changing the behavior of 'Return' in NSTableView
  • Next by Date: Re: Core Data and Document Packages
  • Previous by thread: Re: Dock Size and Position
  • Next by thread: Re: NSNumberFormattter not working
  • Index(es):
    • Date
    • Thread