Created
July 8, 2015 17:17
-
-
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 ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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