how to get first three characters of an NSString?

后端 未结 3 656
旧巷少年郎
旧巷少年郎 2020-12-07 19:57

How can I return the first three characters of an NSString?

3条回答
  •  星月不相逢
    2020-12-07 20:08

     mystr=[mystr substringToIndex:3];
    

    Be sure your string has atleast 3 ch.. o.e. it will crash the app.

    Here are some other links to check NSsting operations...

    Link1

    Link2

    Apple Link

提交回复
热议问题