给定目标 C 中的多个字符拆分 NSString [英] split NSString given a number of characters in objective C

查看:74
本文介绍了给定目标 C 中的多个字符拆分 NSString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个字符串作为我应用程序中文本字段的输入.我知道它们的长度都是 4 个字符.

I have two strings that are taken as input from a textfield in my application. I know that they are both 4 characters in length.

有什么方法可以将这些字符串减半",并为每个原始字符串创建两个字符串,每个字符串有两个字符?

Is there some way I can "halve" those strings, and create two strings per original string that have two characters each?

推荐答案

好的.NSString 有非常有用的方法 "substringToIndex:""substringFromIndex:".这里的幻数(索引)似乎是 2.

Sure. NSString has the very useful methods "substringToIndex:" and "substringFromIndex:". The magic number (index) here appears to be 2.

这篇关于给定目标 C 中的多个字符拆分 NSString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆