Reputation: 23
Please help me, I want to Substring like that " https://stackoverflow.com/questions/ask/abc.pdf " and I want to get " abc.pdf ". It mean I want to get file name of pdf.
Note: it is not the same string. Forexample : https://stackoverflow.com/questions/ask/abc.pdf, https://stackoverflow.com/questions/ask/tosf/abc.pdf and sometime https://stackoverflow.com/questions/ask/tosf/12/abc.pdf
Thanks!
Upvotes: 0
Views: 65
Reputation: 4268
In addition to Rijo answer. No need to create NSURL
instance, you can use lastPathComponent
method of NSString
:
NSString *filename = [@"http://stackoverflow.com/questions/ask/abc.pdf" lastPathComponent];
Upvotes: 1
Reputation: 801
Use the lastPathComponent
method of NSURL.
NSURL *url = [NSURL URLWithString:@"http://stackoverflow.com/questions/ask/abc.pdf"];
NSString *filename = [url lastPathComponent];
Upvotes: 1