Skip to content

Instantly share code, notes, and snippets.

@ThinhPhan
Created July 8, 2015 17:17
Show Gist options
  • Save ThinhPhan/be211b4df6524058aa5a to your computer and use it in GitHub Desktop.
Save ThinhPhan/be211b4df6524058aa5a to your computer and use it in GitHub Desktop.
Check from URL is a image URL or not by checking file's extension. You can check another file type: music or video ...
- (BOOL)isImageURLValid:(NSURL *)imageURL
{
NSArray *imageExtensions = @[@"jpg", @"jpeg", @"png", @"gif", @"tiff"]; // Add more if you want
NSString *extension = [imageURL pathExtension];
for (NSString *ext in imageExtensions) {
if ([ext isEqualToString:extension]) {
return YES;
}
}
return NO;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment