• 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: number formatter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: number formatter
      • From: "J.E. Schotsman" <email@hidden>
References: 
 >number formatter (From: "J.E. Schotsman" <email@hidden>)

  • Prev by Date: Re: Auto Layout Question
  • Next by Date: Re: number formatter
  • Previous by thread: number formatter
  • Next by thread: Re: number formatter
  • Index(es):
    • Date
    • Thread