uzair dhada uzair dhada - 2 months ago 6
Objective-C Question

Get Particular string from NSString

I get

NSString
as
session["token2"] = "Token 90dcee1adc82c25f51fc9542e4f9efd338caa0b5"
and i just want
90dcee1adc82c25f51fc9542e4f9efd338caa0b5
so what is the best way to get that token?

Answer

there are two methods of string, you can use that and get your final token.

NSString *strToken = @"Token 90dcee1adc82c25f51fc9542e4f9efd338caa0b5";

1st method :

NSString *strToken1 = [[strToken componentsSeparatedByString:@" "] lastObject];

2nd method :

NSString *strToken2 = [strToken substringFromIndex:6];

By both method you can get your token.