我在文本字段中有一些文本,它们以 6 个字符开头,我自己的输入也是 6 个字符长,我使用这段代码让它们成为比较的一部分:
unichar aChar1 = [mainTextController.text characterAtIndex:6];
unichar aChar2 = [mainTextController.text characterAtIndex:7];
unichar aChar3 = [mainTextController.text characterAtIndex:8];
unichar aChar4 = [mainTextController.text characterAtIndex:9];
unichar aChar5 = [mainTextController.text characterAtIndex:10];
unichar aChar6 = [mainTextController.text characterAtIndex:11];
现在,当我这样做时,它会暂停我的模拟器,但是当我在 0、1、2、3、4、5 中转动 6、7、8、9、10、11 时,它确实可以工作。怎么会?
(*由于未捕获的异常'NSRangeException'而终止应用程序,原因:'-[__NSCFString characterAtIndex:]:范围或索引超出范围')有人可以向我解释一下