If there is an NSString like “com.mycompany.purchase1” How to get only purchase1.
NSString *mainString = @"com.mycompany.purchase1";
-(NSString*)getLastComponent : (NSString*) mainString
{
NSString *string;
//Implementation
return string;//It should return only "purchase1"
}
I tried using lastPathComponent,pathExtension and also i can’t use substringToIndex since the string may be of varying length.
Don’t want donkim’s answer as he is correct. Just showing the implementation I would use
Use