Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BadWolf13

macrumors 6502
Original poster
Dec 17, 2009
271
0
Hello everyone, got a question about something that I'm not sure which way to go on.

I've got a database that's going to be displayed in a table view. Now one of the items is an integer, but I don't want the table view to display the number, I want it to display a string that corresponds to the integer value. Now I'm not sure which way to go about this. Should I use a custom NSFormatter, or an NSValueTransformer? Or is there a completely different way I should go about this?

PS, the reason I went about using an integer instead of just a string is that the user is only be able to select from a predefined list of values that are presented in a pop-up button in another window.
 
Assuming you're using bindings, I'd just use NSValueTransformer. Bind your object or attribute to the column, then apply the transformer that generates the string.

NSFormatter is more used when you have input that needs to be restricted to a certain format.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.