I do what’s below but I
am uncertain if it can be a problem, because it “works?”
myLabel.text = @"--";
float myString = [myLabel.text floatValue];
NSLog(@"What is myLabel '--' text as a float? %@",myLabel.text);
// output is: '--'
NSLog(@"What is value of myString '--' as float? %2.2f",myString);
// output is: 0.00
I see nothing wrong with the outputs and formats. What i am having a question about is why does
“float myString” convert ‘–‘ to 0.00, this seems like it can be problematic.
If this is not an automatic action, what is the best way to assign a string to the value of 0.00,
after it’s been pulled from a label?
Since
"--"is not a valid float value,floatValuereturns0.0.From the
NSStringdocumentation: