I have a NSString object which is assigned this ("http://vspimages.vsp.virginia.gov/images/024937-02.jpg"). Can anybody tell me how to check whether the string ends with ".jpg"?
if ([[yourString pathExtension] isEqualToString:@"jpg"]){ //.jpg }
or
if ([yourString hasSuffix:@".jpg"]){ //.jpg }
appending to vladimir's answer, you may wish to make a case insensitive comparison. Here's how I did it:
if( [[yourString pathExtension] caseInsensitiveCompare:@"jpg"] == NSOrderedSame ) { // strings are equal but may not be same case }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With