numeric values within NSString are displayed in a wrong locale

numeric values within NSString are displayed in a wrong locale

By : user2953637
Date : November 21 2020, 01:01 AM
may help you . That's odd. I would not force the local but setting it to the local setting of the device and you could set the string format as follows:
code :
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
numberFormatter.locale = [NSLocale currentLocale];
numberFormatter.numberStyle = NSNumberFormatterDecimalStyle;
numberFormatter.maximumFractionDigits = 0;
self.label.text = [NSString StringWithFormat:@"%@", [numberFormatter stringForObjectValue:number]];
NSString *formattedNumberString = [numberFormatter localizedStringFromNumber:number];

Share : facebook icon twitter icon
What locale argument to pass to NSDecimalNumber +decimalNumberWithString:locale: so it always works with NSString's usin

What locale argument to pass to NSDecimalNumber +decimalNumberWithString:locale: so it always works with NSString's usin

By : user3683535
Date : March 29 2020, 07:55 AM
To fix the issue you can do I have an NSString which I want to convert into an NSDecimalNumber. The string is received from a server and is always formatted using the en_US locale like XXX.YYY and not like XXX,YYY. I want to create an NSDecimalNumber which accepts XXX.YYY regardless of the locale the user. The number is never displayed to the user, it's used to do internal math. , This appears to work well, and is more explicit:
code :
NSDictionary    *l = [NSDictionary dictionaryWithObject:@"." forKey:NSLocaleDecimalSeparator];
NSDecimalNumber *n = [NSDecimalNumber decimalNumberWithString:@"1.234" locale:l];
Store Displayed UITableView Cell in NSString if Displayed for 2 Seconds

Store Displayed UITableView Cell in NSString if Displayed for 2 Seconds

Date : March 29 2020, 07:55 AM
I wish did fix the issue. You can use dispatch with delay and the check if cell is still visible
code :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];

    NSDictionary *item;

    if (tableView == self.searchDisplayController.searchResultsTableView){
        item = [[NSDictionary alloc] initWithDictionary:[filteredListItems 
    }else {
        item = [[NSDictionary alloc] initWithDictionary:[listItems 

    if(cell == nil){
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle 

    double delayInSeconds = 2.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

        // nil means that cell is no longer visible so it didn't meet the requirement for 2s displaying
        if ([tableView cellForRowAtIndexPath:indexPath] == nil) {

        NSString *locationId  = [item objectForKey:@"location_id"];

        NSString *scrolledIdPre = [NSString stringWithFormat:@"-%@-", locationId];

        [scrolledIds appendString:scrolledIdPre];

        [[NSUserDefaults standardUserDefaults] setObject:scrolledIds forKey:@"impressions"];
        [[NSUserDefaults standardUserDefaults] synchronize];

    return cell;
NSString Split String Based on Numeric values

NSString Split String Based on Numeric values

By : Michael Spencer
Date : March 29 2020, 07:55 AM
To fix this issue I was hoping to get some assistance with splitting one of my NSString values. Consider the following below: , Try this:
code :
NSArray *array = @[@(3),@(2),@(5)];
NSUInteger loc = 0;
for (int i = 0; i < [array count]; i++) {
    NSUInteger len = [[array objectAtIndex:i] unsignedIntegerValue];
    NSString *subStr = [string substringWithRange:NSMakeRange(loc, len)];
    loc += len;
NSString *string = @"_o_t_d_n__";
const char *c = [string cStringUsingEncoding:NSUTF8StringEncoding];
char *myData = calloc(3, 1);
for (int i = 0, j = 0; i < [string length]; i++, j++) {
    myData[j] = c[i];
    if (i == 2 || i == 4 || i == 9) {
        NSString *string = [[NSString alloc] initWithBytes:myData length:sizeof(myData) encoding:NSUTF8StringEncoding];
        if (i == 2) myData = realloc(myData, 2);
        if (i == 4) myData = realloc(myData, 5);
        j = -1;
Parsing an NSString to find and increment numeric values

Parsing an NSString to find and increment numeric values

By : user3271419
Date : March 29 2020, 07:55 AM
hope this fix your issue I have an string value. , Here is your answer...
code :
- (void)viewDidLoad 
    [super viewDidLoad];

    NSString *getAllData = @"0,testing,u,4,u";
    NSMutableArray *resultArray = [NSMutableArray array];
    [[getAllData componentsSeparatedByString:@","] enumerateObjectsUsingBlock:^(NSString *subString, NSUInteger idx, BOOL *stop) {
        if([self isNumeric:subString])
            [resultArray addObject:[NSString stringWithFormat:@"%d", [subString intValue] + 1]];
        else [resultArray addObject:subString];

    NSString *finalOutput = [resultArray componentsJoinedByString:@","];
    NSLog(@"%@", finalOutput);

- (BOOL)isNumeric:(NSString *)aString
    NSString *expression = [NSString stringWithFormat:@"^[0-9]*$"];
    NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:expression options:NSRegularExpressionCaseInsensitive error:nil];
    NSUInteger numberOfMatches = [regex numberOfMatchesInString:aString options:0 range:NSMakeRange(0, [aString length])];
    return (numberOfMatches != 0);
Android Localization: What am I doing wrong that I can get months be displayed according to the locale?

Android Localization: What am I doing wrong that I can get months be displayed according to the locale?

By : Hector RAG
Date : March 29 2020, 07:55 AM
I wish this helpful for you Your conclusion is logical but toString() is usually and certainly in this case a utility function, meant mainly for debugging.
For localised dates you need to use a DateFormatter, like so:
Related Posts Related Posts :
  • Delete Core Data Entry from Table View Controller
  • How to unload UIViewcontroller from memory?
  • Compressing UIImage as Far as Possible?
  • Optimizing workflow to update internally owned cocoapods dependencies?
  • Formatting an NSDate with Abbreviated Month/Day Names
  • I'm creating a quiz game with 4 answers and I want to add score
  • Tap Gesture to Hide Navigation Bar, Tab Bar, and Status Bar
  • FBSessionStateClosedLoginFailed when I am logged in through Settings
  • CGRect positioning according to center point
  • iOS: Update table view datasource with animations without core data
  • iOS : Where to start for AliPay integration?
  • Routing App Coverage File missing but not needed?
  • Drawing on a zoomable view
  • Append NSStrings and NSNumber to NSMutableArrays and make NSMutable dictionary
  • Terminating app due to uncaught exception 'NSRangeException' when calling dequeueReusableCellWithReuseIdentifier:forInde
  • Collision without physics (Cocos2D + Box2D iOS)
  • Creating a percentage based iOS layout
  • Update tableView row from AppDelegate Swift 4
  • Assigning return value of a class method to a variable error
  • how to display circular progress in delphi ios apps?
  • I can't figure how to fix this Expected identifier or '('
  • How to Test APIs in Swift 4?
  • Link error /Build/Products/Debug-iphonesimulator file not found
  • working with a very large JSON object in iOS
  • Turn off part of the iPhone Screen
  • Phonegap 3.0 app with facebook login using xCode
  • How to add interstitial admob ads to my ios project
  • adding tapku calendar to ios app
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • Sidebar menu with indicate navigationbar on iOS
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • Web services issue on POST method
  • Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass
  • Swift can't send URLRequest at all?
  • No Provisiong profiles with a valid signing identity were found and Failed to locate or generate matching signing assets
  • iOS: how to set httponly flag for NSHTTPCookie
  • How to get the mac address of a beacon in objective-c without knowing its UUID, major and minor values?
  • tableView is not showing data from JSON in swift
  • iTunes reject app for date of birth
  • SWIFT reporting "Extra argument in call" - works in Playground
  • save data depending on passed value in swift
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org