내 첫 번째 질문! 나는 (stackoverflow를 통해 많은 검색을 통해 도움을 얻지 않고)이 RSS 리더의 대부분을 코딩 할 수 있었지만 여기서는 뒤죽박죽이다.NSURL의 끝에서 3자를 어떻게 제거합니까?
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]];
links3 배열은 문자열이있는 NSMutableArray
입니다. 처음 몇 줄은 'urlbase'에 저장되어있는 해당 배열의 각 문자열의 시작 부분에서 공간을 제거하는 데 완벽하게 작동합니다. 그래서 나올 때 잘 보입니다. 우리가 사용하는 경우,
http://www.feedzilla.com/r/D7E6204FEDBFE541314B997AAB5D2DF9CBA2EFEE
을 :하지만 [[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlbase]]
우리는 다음을 참조하십시오 http://www.feedzilla.com/r/D7E6204FEDBFE541314B997AAB5D2DF9CBA2EFEE%0A
나는이 문제를 어떻게 해결할 수 우리가 urlbase를 NSLog 때, 우리는 볼 수? 그 꼬리 요소를 어떻게 든 제거 할 수 있습니까? 감사!
근무 코드 :
NSMutableArray *links3 = [[NSMutableArray alloc] init];
RSSAppDelegate *appDelegate = (RSSAppDelegate *)[[UIApplication sharedApplication] delegate];
links3 = appDelegate.links;
NSLog(@"%@ %i", [links3 objectAtIndex:indexPath.row], 3453);
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);
NSLog(@"%@ %i" , urlbase, 345346);
NSString* fixed = [urlbase stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]];
NSURL *hellothere = [NSURL URLWithString:fixed];
NSLog(@"%@ %i", hellothere, 54);
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:fixed]];
이봐, 난 꽤 있었다 말하지 않았다. 감사합니다 Diederik Hoogenboom!
% 0A는 줄 바꿈 문자 (줄 끝)입니다. 공백 문자이기 때문에 이미 NSLog에서 보이지 않는 urlbase에있을 것입니다. 처음에 어떻게 거기에 넣었는지보십시오. – progrmr