How can I remove leading zeros from an NSString
?
e.g. I have:
NSString *myString;
with values such as @\"0002060\">
In addition to adali's answer, you can do the following if you're worried about the string being too long (i.e. greater than 9 characters):
NSString *str = @"000200001111111";
NSString *strippedStr = [NSString stringWithFormat:@"%lld", [temp longLongValue]];
This will give you the result: 200001111111
Otherwise, [NSString stringWithFormat:@"%d", [temp intValue]]
will probably return 2147483647 because of overflow.