Iphone NSNumberFormatter runs on simulator not on os 4.2 device during parsing

This is a fragment of the terremoto code from Craig Schamp .. works fine on the simulator (os 4.2), but not on the device.

self.currentEarthquake.magnitude = [formatter numberFromString:magString]; and

NSNumber *latituide = [formatter numberFromString:[comp objectAtIndex:0]];

NSNumber *longitude = [formatter numberFromString:[comp objectAtIndex:1]] 

the device has zero, while the simulator has all the data .... here is the whole code .... my 3g device with 4.2 NSNumberFormatter problem ???

if ([elementName isEqualToString:@"title"]) {
  //<title>M 5.8, Banda Sea</title>
  NSArray *components = [self.propertyValue componentsSeparatedByString:@","];
  if (components.count > 1) {
   // strip the M
   NSString *magString = [[[components objectAtIndex:0] componentsSeparatedByString:@" "] objectAtIndex:1];

   NSLog(@"String %@",magString);

   NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
   self.currentEarthquake.magnitude = [formatter numberFromString:magString];
   self.currentEarthquake.place = [components objectAtIndex:1];
   [formatter release];

   NSLog(@"Magnetudine %@",self.currentEarthquake.magnitude);
   NSLog(@"Place %@",self.currentEarthquake.place);

   NSLocale *currentUsersLocale = [NSLocale currentLocale];
   NSLog(@"Current Locale: %@", [currentUsersLocale localeIdentifier]);

  }
 } else if ([elementName isEqualToString:@"updated"]) {
  //<updated>2008-04-29T19:10:01Z</updated>
  NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
  [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
  self.currentEarthquake.lastUpdate = [formatter dateFromString:self.propertyValue];
  [formatter release];

  NSLog(@"Date %@",self.currentEarthquake.lastUpdate);

 } else if ([elementName isEqualToString:@"georss:point"]) {
  NSArray *comp = [self.propertyValue componentsSeparatedByString:@" "];
  NSLog(@"Comp %@",comp);

  NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];


  NSNumber *latituide = [formatter numberFromString:[comp objectAtIndex:0]];
  NSLog(@"Latitude %@",latituide);
  NSNumber *longitude = [formatter numberFromString:[comp objectAtIndex:1]];
  [formatter release];
  CLLocation *location = [[CLLocation alloc] initWithLatitude:latituide.floatValue
                longitude:longitude.floatValue];
  self.currentEarthquake.location = location;
  [location release];

  NSLog(@"Location %@",location);
 } else if([elementName isEqualToString:@"entry"]) {
  [(id)[self delegate] performSelectorOnMainThread:@selector(addEarthquake:)
             withObject:self.currentEarthquake
             waitUntilDone:NO];
 }

2010-12-05 03: 46: 45.738 Terremoto [251: 307] Comp ("41.9022", "12.4579") 2010-12-05 03: 46: 45.745 Terremoto [251: 307] Latitude (zero)

2010-12-05 03: 46: 45.847 Terremoto [251: 307] Location <+0.00000000, +0.00000000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 05/12/10 03: 46: 45 GMT-03: 00

2010-12-05 03: 46: 45.854 Terremoto [251: 307] Line 5.0

2010-12-05 03: 46: 45.864 Terremoto [251: 307] Magnetudine (null)

2010-12-05 03: 46: 45.868 [251: 307] Hotel Ergife

2010-12-05 03: 46: 45.871 Terremoto [251: 307] Current Locale: it_IT

2010-12-05 03: 46: 45.892 [251: 307] 2010-10-14 14:35:18 +0000

2010-12-05 03: 46: 45.898 [251: 307] Comp (    "-6,1020",    "127.5017" )

+3
2

, , , () "." .

-[NSNumberFormatter setDecimalSeparator:], .

+6

( ). iOS 4.3. mac, iPad, , , IMO- , .

:

 pi.latitude = [NSNumber numberWithDouble:[(NSString *)[coords objectAtIndex:0] doubleValue]];

.

+1

Source: https://habr.com/ru/post/1778527/


All Articles