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
我有一个应用程序,其中有一个用于表单输入的模板。
由于页面上将有相同输入/标签的多个版本,因此输入 ID 不能被硬编码。
相反,我构建了一个用于绑定 attr 的函数('id' 用于输入,'for' 用于标签)。
这在 Chrome 和 IE9 中效果很好,但在 IE8 和 IE7 中失败。
我有一个标签和输入:<