Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的字符串:
NStrring x=@"D1 - Damages";
当我发出[x substringFromIndex:2] 我得到 的- 结果是损害而不是得到 D1
[x substringFromIndex:2]
我只需要将 D1 作为返回的字符串,但上面的语句是删除 D1 并返回字符的其余部分。
您需要使用substringToIndex:2来获取D1. 您正在使用substringFromIndex的基本上是从索引 2 开始获取字符串,这将为您提供- Damages
substringToIndex:2
D1
substringFromIndex
- Damages