Reputation: 1439
I have NSString in the following format
NSString *string1 = @"webservices/employee/1";
and another string with
NSString *string2 = @"webservices/manaager/1";
I want to get the string in between "werbservice/" and "/1" using a common method.
Is there any way to do this?
Upvotes: 2
Views: 1542
Reputation: 12787
use this method for deviding the string - (NSArray *)componentsSeparatedByString:(NSString *)separator
use like this
-(NSString *)returnComponent:(NSString *)str
{
NSString *returnString=[[str componentsSeparatedByString:@"/"] objectAtIndex:1];
return returnString;
}
Upvotes: 0
Reputation: 2699
[[string componentsSeparatedByString:@"/"] objectAtIndex:1]
Upvotes: 7