Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added currency cells. #575

Closed
wants to merge 1 commit into from
Closed

Added currency cells. #575

wants to merge 1 commit into from

Conversation

cbh2000
Copy link

@cbh2000 cbh2000 commented Sep 24, 2015

I added two currency cell styles: one with cents and one without. They're internationalized too. Values are stored internally as NSDecimalNumber to avoid precision loss.

example

internationalization

@ziogaschr
Copy link
Contributor

You can also use something like #306 & #195 & #77 (all are the same) for achieving the same without adding a new cell type.

@cbh2000
Copy link
Author

cbh2000 commented Sep 24, 2015

@ziogaschr Almost.

While adding a NSFormatter will enable currency formatting, NSNumberFormatter's currency formatting is extremely picky about the format (user can type 1 000 € but not 1 000€ or 1 000 or 1000). And the decimal pad keyboard doesn't have a currency symbol, so we'd have to use the standard keyboard.

If we use a decimal field for currency, you'll find it has precision issues (try typing in "8.14," it displays as "8.1400000000...1"). In the end, the user would have to create their own cell or use a text cell with a decimal pad and no formatter.

If we'd rather not add another cell type, would you be ok if I exposed the textfield delegate methods of XLFormTextFieldCell in another PR? Right now I can't override them without resorting to hacks.

@ziogaschr
Copy link
Contributor

This is exactly how it works using an NSFormatter. Except that you don't have a currency symbol in the keyboard. Although from what I can see from your GIF's you have a single currency sign predefined.

simulator screen shot sep 25 2015 10 58 02
simulator screen shot sep 25 2015 10 57 53

@cbh2000
Copy link
Author

cbh2000 commented Sep 25, 2015

I like @ziogaschr's PR better. It's more generic and offers the same functionality. 😄

@cbh2000 cbh2000 closed this Sep 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants