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

Locale - specific string to number converter issue #7

Open
ghost opened this issue Nov 29, 2013 · 1 comment
Open

Locale - specific string to number converter issue #7

ghost opened this issue Nov 29, 2013 · 1 comment

Comments

@ghost
Copy link

ghost commented Nov 29, 2013

Hi!

I've encountered with string to number conversion issue
Server sends me the data with US decimal delimiter - basically dot.
But my local decimal delimiter on iOS device is comma.

So i've got nill after string to number conversions
Here is a class with issue

@implementation PicoNumberConverter

-(NSString *)write:(NSNumber *)value withConfig:(PicoConfig *)config {
    NSString *result = [value stringValue];
return result;
}

 -(NSNumber *)read:(NSString *)value withConfig:(PicoConfig *)config {
NSNumber *result = [config.numberFormatter numberFromString:value];
if (!result){
    result = @([value doubleValue]);
}
return result;
}

@end

Maybe we should add some type of exception or logger message for such cases?

@bulldog2011
Copy link
Owner

Hi,

You may provide a customized PicoConfig instance on the calling client, on the customized PicoConfig instance, you may adjust the NSNumberFormatter for your case.

reference:
https://developer.apple.com/library/mac/documentation/cocoa/reference/Foundation/Classes/NSNumberFormatter_Class/Reference/Reference.html

Thx!
-William

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

No branches or pull requests

1 participant