> On May 24, 2017, at 9:30 AM, J.E. Schotsman <jesc...@xs4all.nl> 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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to