Sunday, December 22, 2013

Get file name and extension from URL path

How to get file name with extension in a URL path is relatively straight forward in iOS. 

The code below should work. Put your url into a NSURL variable named yourURL or whatever. Then type the below:

 NSString *JPEGfilename = [[yourURL absoluteString] lastPathComponent];

This will give you your JPEG filename or below:

 NSURL *yourURL = [NSURL urlWithString:@"http://www.hdwallpapers.in/walls/honda_v4_concept_widescreen_bike-wide.jpg"];
 NSString *JPEGfilename = [yourURL lastPathComponent];

No comments:

Post a Comment

Generating "Always On Top" NSWindow in macOS across all detected displays

Also: Using UIKit & Cocoa Frameworks using Objective-C In m acOS or OS X , written in either Objective-C or Swift  Langues, you m...