これは難しい質問の答えにはなりませんが、URL を特定のドメインのホワイト リストと照合している場合 (この質問を見つけたときのように)、次のようなコードを使用して確認できます。
NSArray *domainsForVideo = @[@"youtube.com",
@"youtu.be",
@"videoschool.pvt.k12.md.us",
@"vimeo.com"];
NSString *host = [url host]; //where URL is some NSURL object
BOOL hostMatches = NO;
for (NSString *testHost in domainsForVideo) {
if ([[host lowercaseString] isEqualToString:testHost]) hostMatches = YES; // matches youtube.com exectly
NSString *testSubdomain = [NSString stringWithFormat:@".%@",testHost]; // matches www.youtube.com but not fakeyoutube.com
if ([[host lowercaseString] rangeOfString:testSubdomain].location != NSNotFound) hostMatches = YES;
}
if (hostMatches) {
// this is a Video URL
}