I have a string percentage in an array that I’d like to convert to a double. Obviously I have to both remove the percentage and then do something along the lines of [string doubleValue]. What is the most efficient way of removing the %? The action is repeated often so the method must be somewhat resource conservative.
I have a string percentage in an array that I’d like to convert to
Share
As long as your string begins with a valid text representation of a floating-point number (it can only contain whitespace at the beginning), you can call
doubleValueand omit any preprocessing of the string.