我想从这样的字符串中提取文件名
C:\IBM\...\images\custom\fileName.png
但是
[string lastPathComponent];
给我整个字符串而不是 fileName.png。我在这里做错了什么?
最佳答案
我相信 lastPathComponent
根据正斜杠“/”拆分,您的路径只包含反斜杠“\”
您可以尝试替换反斜杠:
[path stringByReplacingOccurrencesOfString:@"\\" withString:@"/"].lastPathComponent;
关于ios - [string lastPathComponent] 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23506295/