Monday, June 28, 2010

pull data from string

lets say locationString = 1,2,3,4

NSLog(@" GEO MAP is %@",locationString);

//NSString *myData = [NSString stringWithContentsOfFile:myPath];
NSArray *posArray = [[NSArray alloc] initWithArray:[locationString componentsSeparatedByString:@","]];
NSLog(@"count = %d",[posArray count]);
NSLog(@"first one = %f", [[posArray objectAtIndex:2] floatValue]);
NSLog(@"2nd one = %f", [[posArray objectAtIndex:3] floatValue]);


output will be 3,4

FEEDJIT Live