I try to read out the url's of youtubevideos from this link: http://gdata.youtube.com/feeds/api/videos?author=channelname

I tried it like this:

NSRange startRange = [ret rangeOfString:@"<media:content url='http"];
NSRange endRange = [ret rangeOfString:@"'"];

NSRange searchRange = NSMakeRange(startRange.location , endRange.location);
NSLog(@"Link: %@",[ret substringWithRange:searchRange]);

The output is just: <media:content

Where is my mistake?

有帮助吗?

解决方案

Where is my mistake?

The mistake is that you're not using the right tool for the task.

Anyways, you seem to be confusing the length and the ending location of ranges. NSMakeRange() takes a location and a length, not the starting and the ending location.

Also, don't expect - [NSString rangeOfString:] to magically guess what you are trying to do. It will return the first occurrence of the given substring, and here that is not what you want.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top