How do I remove 3 characters from the end of an NSURL?
Posted
by saywhatman
on Stack Overflow
See other posts from Stack Overflow
or by saywhatman
Published on 2010-05-16T21:13:28Z
Indexed on
2010/05/16
21:20 UTC
Read the original article
Hit count: 143
Hey, my first question! I've been able to code up most of this RSS reader without enlisting help (through a lot of searches through stackoverflow!) but I'm stumped here.
NSString *urlbase = [[NSString alloc] initWithFormat:[links3 objectAtIndex:indexPath.row]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlbase]];
NSCharacterSet *whitespaces = [NSCharacterSet whitespaceCharacterSet];
NSPredicate *noEmptyStrings = [NSPredicate predicateWithFormat:@"SELF != ''"];
NSArray *parts = [urlbase componentsSeparatedByCharactersInSet:whitespaces];
NSArray *filteredArray = [parts filteredArrayUsingPredicate:noEmptyStrings];
urlbase = [filteredArray componentsJoinedByString:@" "];
NSLog(@"%@ %i" , urlbase, 4353);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlbase]];
The links3 array is a NSMutableArray with strings. The first few lines work flawlessly in eliminating the space at the beginning each string from that array, which is stored in 'urlbase' so they look fine when they come out. When we NSLog urlbase, we see:
http://www.feedzilla.com/r/D7E6204FEDBFE541314B997AAB5D2DF9CBA2EFEE
But, when we use: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlbase]]
We see: http://www.feedzilla.com/r/D7E6204FEDBFE541314B997AAB5D2DF9CBA2EFEE%0A
How can I fix this? Can I remove those tail elements somehow? Thanks!
© Stack Overflow or respective owner