0

Possible Duplicate:
Struggling with currency in Cocoa
Re-Apply currency formatting to a UITextField on a change event

I have been all over the web and either examples are no longer valid or people didn't really know what they were doing. So i have come to you guys for help,

I need to get a a textbox(TextField) to Display when they click into it a "$"...that was Easy lol

but i also need from the dollar sign to $0.00 then $0.01, $0.10 and so on.

And save an instance of it without the Symbols.

I am very new to Objective C and would like maybe a simple explanation or even a good blog to read about it. "only if you just recently read it and its not outdated"

Community
  • 1
  • 1
Keeano
  • 309
  • 8
  • 33
  • not, yelling.....the title i had caps on, sorry and there at the bottom, i am simply stating a point people will easily look over. – Keeano Sep 07 '11 at 17:21
  • @Carl Norum tried that post, didnt work. – Keeano Sep 07 '11 at 17:28
  • Also @Malcolm Box tried the answer to that same post, couldnt get a result. – Keeano Sep 07 '11 at 17:29
  • 1
    Please explain in your question exactly why those posts do not apply to your problem, because they both have excellent answers already. – jscs Sep 07 '11 at 17:59
  • 1
    Saying "tried X, didn't work" won't get you the help you need here or anywhere else. You have to say what results you got, and how those differ from what you need – Malcolm Box Sep 07 '11 at 20:10

1 Answers1

2

You want to use NSNumberFormatter to accomplish this. The NSNumberFormatter documention from Apple is very good (I've just re-read it and it's not outdated). Specifically, look at the section on Configuring the Format of Currency. This should be enough to get you started.

Another good place to look if you prefer examples to documentation, is to read through the section on Number Formatters from Apple's Data Formatting Guide. This goes through examples of how to set up currency formatters to your specifications with concrete examples.

Finally, in order to integrate this with a UITextField, you will want to use the delegate method

– textField:shouldChangeCharactersInRange:replacementString:

This allows you to validate and update characters as the user types them in.

PengOne
  • 48,188
  • 17
  • 130
  • 149
  • i could have asked a better question._How would i put that info together to get the result im looking for?_ i have spent 3 hours on this now, and i know the answer will not just be given but i want to learn it. For some reason i cant understand Objective c, complete methodology of conversions....Mainly just strings. – Keeano Sep 07 '11 at 17:24
  • 2
    @Keeano: If you spent 3 hours, then spend a few minutes being clear in your question and show us what you've tried. The more specific a question and the more evidence that the OP has spent time on it, the more time I spend crafting a more specific answer. – PengOne Sep 07 '11 at 17:28
  • Thank you, that's the information i was looking for! and thanks for helping and enjoying to answer a question instead of complain that it may be Close to another question! – Keeano Sep 07 '11 at 17:32
  • 1
    @Keeano - the solution given is exactly the same as the *fuller* solution listed in http://stackoverflow.com/questions/2388448/re-apply-currency-formatting-to-a-uitextfield-on-a-change-event – Malcolm Box Sep 07 '11 at 20:12
  • yeah, i realized that now. apologies! – Keeano Sep 07 '11 at 20:26