Tagged Questions

NSFormatter is an abstract class that declares an interface for objects that create, interpret, and validate the textual representation of cell contents. The Foundation framework provides two concrete subclasses of NSFormatter to generate these objects: NSNumberFormatter and NSDateFormatter.

I have a NSTextField with a number formatter set this way:
NSNumberFormatter *myFormatter = [[NSNumberFormatter alloc] init];
[myFormatter setFormatWidth:7];
[myFormatter setPaddingCharacter:@"0"];
...

I have a textfield which has to be unique so I added my custom NSFormatter (see below)
The formatter works, as you can see on the screenshot, but the continuous binding, which I am using is broken, ...

When logging-out a float in Objective-C you can do the following to limit your output to only 2 decimal places:
float avgTemp = 66.844322156
NSLog (@"average temp. = %.2f", avgTemp);
But how do you ...

Is there any way to get an NSNumberFormatter (or presumably any other NSFormatter) to work in an NSPopover?
The NSTextField's value in the popover is bound to an NSViewController's representedObject. ...

I am trying to calculate the number of characters in an NSString which has been formatted from decimal numbers with localisation.
Using the code below, I get the lengths correctly in UK localisation. ...

With a NSTextField we can easially call setFormatter if we want to say for instance create a custom formatter that only allows numbers (take this question for example).
But what if we want to apply a ...

I have a float value, what i need is convert my float to date. For example i have float 50,55, i want to put on a label value like this: 50 years 6 month 6 hours 6 mins 30,04 sec.
And i wonder how to ...

I'm trying to format two NSTextFields for SMPTE time codes, which have the format:
HH:MM:SS:FF. However, when the user switches the SMPTE code to drop-frame, the delimiter between SS and FF needs to ...

I have a NSTextView and i have a custom NSFormatter that limits the string length. But how do i "[_textView setFormatter:customFormatter]" on a NSTextView? I can't find how to do that.
Example code ...

I have a custom NSFormatter linked to 4 NSTextFields. When I change the values of my text fields manually, everything works fine. But when I change it through a combo box. I get an error looking like ...

My app accesses a poor web service that returns output like this:
Title\n\nInfo1\nInfo2\nInfo3\n ...
To clarify, the text is not literally ..., and the info is not literally numbered, I just wanted ...

I would like to use a custom NSFormatter to judge the length of a string inside of a NSTokenField.
I have implemented the NSFormatter and hooked it up within the xib and all that, now when I get to ...

I want to colorize the first char in the input string. It can be done easily with controlDidChange delegate method. But after adding formatter using:
[field setFormatter:[[MyFormatter alloc] init]];
...

In Qt and in C#, I am able to easily define a input mask for things like phone numbers and serial numbers. Everything I have read so far leads me to believe that NSFormatter is the answer, but I am ...

In Cocoa, I have an NSOutlineView where the cells are NSTextFieldCell. The cell displays values which are strings that are formatted according to certain rules (such as floats or pairs of floats with ...

This question is similar to this one: http://stackoverflow.com/questions/821363/how-do-i-use-an-nsformatter-subclass-with-an-nspopupbutton
As mentioned in that question, it seems like the 'formatter' ...

I have a 10.4 style date formatter applied to an NSTextFieldCell. I call setTwoDigitStartDate: (tried with both the epoch date and the "reference" date) but when I type in a date with a two digit year ...

I want to use an NSFormatter subclass to format the contents of an NSPopUpButton I'm using to display a list of choices.
Basically I have an NSArray of MyObjects which is bound to the NSPopUpButton ...