I have a NSString
which looks like this:
http://fiskltd.com/components/com_jshopping/files/img_products/thumb_09afd9f041af34fb0cffec1e0b1222e8.jpg
And I need extract from that this string:
thumb_09afd9f041af34fb0cffec1e0b1222e8.jpg
I will have lots of such strings, so I won't know the number of characters and how many of them will the name of the picture. Can anyone tell me how to extract the name of picture?
Try this:
NSString *originalString = @"http://fiskltd.com/components/com_jshopping/files/img_products/thumb_09afd9f041af34fb0cffec1e0b1222e8.jpg";
NSString *filename = [originalString lastPathComponent];
Apple docs here.
可能是你的情况下最好的解决方案是[NSString lastPathComponent]
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.