when i initialize NSString which i get from database,when i print NSLog ,it gives correct URl,but when open through safari, the URL consists %d at the end, how can i remove it?
A:
Or... if you know it always appears at the end of the string you could just slice it:
You could try this to remove the %d:
NSString *formattedString = [originalString stringByReplacingOccurencesOfString:@"%d" withString:@""];
That just replaces any %d with nothing... effectively removing it.
Or... if you know it always appears at the end of the string you could just slice it:
NSString *formattedString = [originalString substringToIndex:[originalString length] - 2];
imnk
2010-01-18 13:07:18
What if the URL already has some other %d in it that we want to keep intact - your answer would break it. It's probably better to work out where the %d is coming from!
deanWombourne
2010-01-18 13:26:31
True. I've updated. thx.
imnk
2010-01-22 03:16:34