Gam*_*ing 262
mystr=[mystr substringToIndex:3];
Run Code Online (Sandbox Code Playgroud)
确保你的字符串至少有3个字符串.它会使应用程序崩溃.
以下是一些检查NSsting操作的其他链接......
dre*_*lax 61
首先,您必须确保该字符串包含至少3个字符:
NSString *fullString = /* obtain from somewhere */;
NSString *prefix = nil;
if ([fullString length] >= 3)
prefix = [fullString substringToIndex:3];
else
prefix = fullString;
Run Code Online (Sandbox Code Playgroud)
substringToIndex: 如果您提供的索引超出字符串的末尾,则会抛出异常.
| 归档时间: |
|
| 查看次数: |
84986 次 |
| 最近记录: |