有没有一种简单的方法来以编程方式获取字母? [英] Is there an easy way to programmatically get the alphabet?

查看:89
本文介绍了有没有一种简单的方法来以编程方式获取字母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个包含字母表中所有字母的 NSArray / NSMutableArray 。必须有一种快速简便的方法,而不是将它们全部输入。例如在PHP中:

I want an NSArray/NSMutableArray containing all the letters of the alphabet. There must be a quick and easy way, better than typing them all out. For example in PHP:

foreach(range('A','Z') as $i) $alphabet[]=$i;


推荐答案

没有比将它们全部键入更快的方法了,除非您可以从下面剪切并粘贴我的方便引用!

There's no quicker way than typing them all out, unless you cut and paste my handy reference from below!

abcdefghijklmnopqrstuvwxyz

"abcdefghijklmnopqrstuvwxyz"

为此,这是一个更长的方法。

For the sake of it, here's a longer way.

for (char a = 'a'; a <= 'z'; a++)
{
  [myArray addObject:[NSString stringWithFormat:@"%c", a]];
}

这篇关于有没有一种简单的方法来以编程方式获取字母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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