获取字符串中的前十个字符

Mil*_*ilo 3 string cocoa-touch nsstring

我正在为我的应用程序添加一个记事本功能,我想读取字符串的前十个字符,并使用该字符串作为表格视图中单元格的标题.

我想我可以用substringFromIndex:.

有人可以详细说明我该如何做到这一点?

Yoe*_*eri 8

[@"1234567890" substringToIndex:6]
Run Code Online (Sandbox Code Playgroud)

给你 123456

  • substringFromIndex - 从给定索引到结尾(apple docs)
  • substringToIndex - 返回一个新字符串,其中包含接收者的字符,但不包括给定索引处的字符(apple docs)