开发者

string manipulation with objective-c

开发者 https://www.devze.com 2023-01-07 18:26 出处:网络
I have a string like this a web url \"https://stackoverfl开发者_Go百科ow.com/questions/3260091/databases-and-deep-copy\"

I have a string like this a web url

"https://stackoverfl开发者_Go百科ow.com/questions/3260091/databases-and-deep-copy"

how can i get the second to last section of the url?

3260091


NSURL * url = [NSURL URLWithString:@"http://stackoverflow.com/questions/3260091/databases-and-deep-copy"];  //or however you get this url

NSString * path = [url path];
NSArray * components = [path pathComponents];

NSString * questionID = [components objectAtIndex:[components count]-2];
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号