function to get the file name of an URL

前端 未结 6 1888
时光说笑
时光说笑 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:33

    Try this:

    Edit: from blow comment

    NSString *url = @"http://www.google.com/a.pdf";
    NSArray *parts = [url componentsSeparatedByString:@"/"];
    NSString *filename = [parts lastObject];
    

提交回复
热议问题