是否可以增加一个字母,即A + 1 = B 在 Objective-C 中?
我习惯在 C 或 C++ 中这样做,即:
myChar++;
应该增加一个字母。
我试图在 Objective-C 中做同样的事情,除了我有一个 NSString 开始(NSString 总是只有一个字母)。我尝试过将 NSString 转换为 char *,但此方法已被弃用,并且其他实现此目的的方法似乎不起作用。
我应该如何将 NSString 转换为 char * - 或者,有没有办法在 Objective-C 中增加字符而不需要 char * ?
谢谢 :)
I am used to doing this in C or C++, ie:
myChar++;
should increment a letter.
I am trying to do the same in Objective-C, except that I have a NSString to start off with (the NSString is always just one letter). I have tried converting the NSString to a char *, but this method is deprecated and other ways of achieving this don't seem to work.
How should I convert an NSString to a char * - or, is there a way to increment a character in objective-c without needing a char * somehow?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,这假设递增 Unicode 字符是有意义的,这对于 ASCII 范围字符有效,但对于其他字符可能无效。
Of course, this assumes incrementing a Unicode character makes sense, which does for ASCII-range characters but probably not for others.
怎么样?
NSString 的效果
How about NSString's
Would that work?