gpt4 book ai didi

cocoa - 使用 Objective-C 进行字符串操作

转载 作者:行者123 更新时间:2023-12-03 17:36:49 24 4
gpt4 key购买 nike

我有一个这样的字符串网址

"https://stackoverflow.com/questions/ 3260091/databases-and-deep-copy"

如何获取网址的倒数第二部分?

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];

关于cocoa - 使用 Objective-C 进行字符串操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3260271/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com