Both work, but... Which one would you use and why ?
@implementation NSString (Extender)
-(NSString *) stringByTrimmingPrefix:(NSString *)strPrefix
{
while ([self hasPrefix:strPrefix])
{
self = [self substringFromIndex:strPrefix.length];
}
return self;
}
@end
or
@implementation NSString (Extender)
-(NSString *) stringByTrimmingPrefix:(NSString *)strPrefix
{
NSString *returnValue = [NSString stringWithString:self];
while ([returnValue hasPrefix:strPrefix])
{
returnValue = [returnValue substringFromIndex:strPrefix.length];
}
return returnValue;
}
@end