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

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

问题描述

我想要一个包含字母表中所有字母的 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天全站免登陆