如果存在像“com.mycompany.purchase1”这样的NSString如何仅获取purchase1。字符串操作
NSString *mainString = @"com.mycompany.purchase1";
-(NSString*)getLastComponent : (NSString*) mainString
{
NSString *string;
//Implementation
return string;//It should return only "purchase1"
}
我尝试使用lastPathComponent,pathExtension并且还我不能使用substringToIndex由于串可以是不同长度的。
+1确定那么这是内置函数用于查找字符串中的最后一个组件。 – Ishu 2010-12-20 06:03:42