Convert string value into float value
How do I convert a string to a float in Objective-C?
I am trying to add a couple of strings I am getting back from XML:
float subTotal = [[[[pintsary objectAtIndex:i]objectForKey:@"Price"] floatValue];
NSLog(@"%@",subTotal));开发者_开发知识库
but it gives error
NSLog(@"%@",subTotal);
is wrong: You want to print a float value, not an object. Use %f
instead.
精彩评论