function to get the file name of an URL

前端 未结 6 1827
时光说笑
时光说笑 2021-01-30 05:23

I have some source code to get the file name of an url

for example:

http://www.google.com/a.pdf

I hope to get a.pdf

because the way to join 2 NSS

6条回答
  •  不思量自难忘°
    2021-01-30 05:40

    I think if you have already had the NSURL object, there is lastPathComponent method available from the iOS 4 onwards.

    NSURL *url = [NSURL URLWithString:@"http://www.google.com/a.pdf"];
    NSString *filename = [url lastPathComponent];
    

提交回复
热议问题