从一个字符串中得到末尾字符串

/Application/Mobile/Lib/123.abc中获取123.abc。123.abc的长度不是固定的。

应该怎么做?

NSString *fileName=[str lastPathComponent];

使用NSStringlastPathComponent方法

NSString *myString = @"/Application/Mobile/Lib/123.abc";
NSString *lastPath = [myString lastPathComponent];
//lastPath would be equal to 123.abc (or whatever the last path component is.