Skip to content

Locale - specific string to number converter issue #7

@ghost

Description

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions