Re: number formatter
Re: number formatter
- Subject: Re: number formatter
- From: Richard Charles <email@hidden>
- Date: Wed, 24 May 2017 10:51:32 -0600
> On May 24, 2017, at 9:30 AM, J.E. Schotsman <email@hidden> wrote:
>
> Hello
>
> I have written the simplest of formatters:
>
> class MyIntNumberFormatter:NumberFormatter
> {
> override init()
> {
> super.init()
> hasThousandSeparators = false
> }
>
> required init?( coder aDecoder:NSCoder )
> {
> super.init( coder: aDecoder )
> }
> }
>
> I can set it as formatter for a text field in code and it works but I cannot set it in the xib.
> When I control-drag the only option I get is to set it as the delegate.
> What am I missing here?
The nib can instantiate the formatter and then you should change class of the formatter in the nib from NumberFormatter to MyIntNumberFormatter. In other words the nib or xib should already contain the formatter, if not then create one. Connect the formatter to your control as you normally would. Then set the class of the formatter to your custom class. When the nib awakes it will instantiate a formatter using your custom subclass.
--Richard Charles
_______________________________________________
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