How to take NSString after specific character which occurs multiple time in NSString?

試著忘記壹切 提交于 2019-12-01 23:17:08

[string lastPathComponent] should do the trick

If it's about the filename in a URL you should definitely create an NSURL object and query that object for the desired information:

NSURL *url = [NSURL URLWithString:@"http://www.mywebsite.com//Folder /Detals /Final Image /La Image Logo.jpg"];
NSString *filename = [url lastPathComponent];

NSURL is good at parsing URL strings. This way you're sure that you don't get any fragment part ("#anchor") or parameters ("?q=foo&p=bar") in your filename.

You can use NSString *string=[[yourString componentsSeparatedByString:@"/"] lastObject]

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!