Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 如何使用NSString打印目标c中的所有字母(a到z)_Objective C - Fatal编程技术网

Objective c 如何使用NSString打印目标c中的所有字母(a到z)

Objective c 如何使用NSString打印目标c中的所有字母(a到z),objective-c,Objective C,我已经创建了NSString实例,并使用该实例来分别打印所有字母 我是IOS新手…提前谢谢。如果您记录了所有字母a到z,那么您可以使用: for (char c = 'a'; c <= 'z'; c++) { NSString *firstLetter = [NSString stringWithFormat:@"%c", c]; NSLog("%@",firstLetter); } for(char c='a';c如果记录所有字母a到z,则可以使用: for (char c

我已经创建了NSString实例,并使用该实例来分别打印所有字母


我是IOS新手…提前谢谢。

如果您记录了所有字母a到z,那么您可以使用:

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

for(char c='a';c如果记录所有字母a到z,则可以使用:

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

for(char c='a';c但如果要打印NSString中的所有字母,请使用以下命令:

NSString *string = @"abcd";
for (NSUInteger index = 0; index < string.length; index++) {
    unichar letter = [string characterAtIndex:index];
    NSLog(@"%c", letter);

}
NSString*string=@“abcd”;
对于(整数索引=0;索引
但如果您想打印NSString中的所有字母,请使用以下选项:

NSString *string = @"abcd";
for (NSUInteger index = 0; index < string.length; index++) {
    unichar letter = [string characterAtIndex:index];
    NSLog(@"%c", letter);

}
NSString*string=@“abcd”;
对于(整数索引=0;索引
我为您编写了一个程序,它将以NSString格式打印所有字母表

    int a = 65;
    NSString *strAlphabets;
    for (; a < 91; a++) {
        if(strAlphabets){
    strAlphabets = [NSString stringWithFormat:@"%@ %c",strAlphabets,(char)a];
    }else{
        strAlphabets = [NSString stringWithFormat:@"%c",(char)a];
    }
    }
    NSLog(@"%@", strAlphabets);
inta=65;
NSString*strAlphabets;
对于(;a<91;a++){
if(strAlphabets){
strAlphabets=[NSString stringWithFormat:@“%@%c”,strAlphabets,(char)a];
}否则{
StralHabets=[NSString stringWithFormat:@“%c”(字符)a];
}
}
NSLog(@“%@”,strAlphabets);

我为您编写了一个程序,它将以字符串形式打印所有字母表

    int a = 65;
    NSString *strAlphabets;
    for (; a < 91; a++) {
        if(strAlphabets){
    strAlphabets = [NSString stringWithFormat:@"%@ %c",strAlphabets,(char)a];
    }else{
        strAlphabets = [NSString stringWithFormat:@"%c",(char)a];
    }
    }
    NSLog(@"%@", strAlphabets);
inta=65;
NSString*strAlphabets;
对于(;a<91;a++){
if(strAlphabets){
strAlphabets=[NSString stringWithFormat:@“%@%c”,strAlphabets,(char)a];
}否则{
StralHabets=[NSString stringWithFormat:@“%c”(字符)a];
}
}
NSLog(@“%@”,strAlphabets);

我做到了,谢谢。@AbhilashGupta欢迎您,如果我的回答对您有帮助,请将其交给正确的mark。这将对其他开发人员和用户有帮助。我做到了,谢谢。@AbhilashGupta欢迎您,如果我的回答对您有帮助,请将其交给正确的mark。这将对其他开发人员和用户有帮助。谢谢谢谢你帮了我。谢谢你帮了我。