Im trying to convert the contentOffset
from a ScrollView into a string.
I have tried many ways but the closest I got was:
label.text = [NSString stringWithFormat:@"%@", NSStringFromCGPoint([self.mainScrollView contentOffset])];
This worked but I the label has the value inside {}
{0, 0}
Does anyone know how to remove the {}
or have a better way?
Thanks
EDIT: about 30 seconds after asking I found this to work:
label.text = [NSString stringWithFormat:@"%02f KM", _mainScrollView.contentOffset.y];
Thanks for everyones help.
Try with following code
NSString *contentOffSet = [NSString stringWithFormat:@"%@", NSStringFromCGPoint([self.mainScrollView contentOffset])];;
NSString *removeBreckets = [contentOffSet stringByTrimmingCharactersInSet: [NSCharacterSet characterSetWithCharactersInString:@"{}"]];
label.text = removeBreckets;