Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.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
Iphone 单字符撇号比较问题_Iphone_Objective C_Sdk_Nsstring_Unichar - Fatal编程技术网

Iphone 单字符撇号比较问题

Iphone 单字符撇号比较问题,iphone,objective-c,sdk,nsstring,unichar,Iphone,Objective C,Sdk,Nsstring,Unichar,我现在看到的是像这样的字符串的一部分 if (thisChar == 'a') [self a]; else if (thisChar == 'b') [self b]; else if (thisChar == 'c') [self c]; else if (thisChar == '0') [self zero];

我现在看到的是像这样的字符串的一部分

            if (thisChar == 'a')
            [self a];

        else if (thisChar == 'b')
            [self b];

        else if (thisChar == 'c')
            [self c];

        else if (thisChar == '0')
        [self zero];

    else if (thisChar == '1')
        [self one];

    else if (thisChar == '2')
        [self two];

    else if (thisChar == '3')
        [self three];

            else if (thisChar == '.')
        [self period];

    else if (thisChar == ',')
        [self comma];

    else if (thisChar == '?')
        [self qmark];
不过,当我谈到这个问题时,问题就出现了

else if (thisChar == ''')
        [self three];
我想要的是((撇号)符号,但它不允许我这么做。我知道原因,但我不知道如何解决。这样做会有帮助吗

NSString *apostropheString = [[NSString alloc] initWithFormat:@"'"];

unichar apostrophe = [apostropheString characterAtIndex:0];
我能用一根等质量线吗

if ([apostrophe isEqualToString: thisChar]) 
任何帮助都将不胜感激


我通过以下几点找到了解决问题的方法:

1) 。使用单字符撇号创建字符串

NSString *apostropheString = [[NSString alloc] initWithFormat:@"'"];
2) 。让它将其转换为名为“app”的unichar,因为它的索引为零,并且只有一个字符的索引为0

unichar app = [apostropheString characterAtIndex:0];
3) 。然后我说如果“thisChar”等于“app”运行“qmark”


我希望这对任何有同样问题的人都有帮助

你必须用反斜杠避开撇号:
'\'

别担心,我已经找到了解决方法!查看编辑信息。它工作!谢谢,我想这比我的方式好,因为它比较短。
else if (thisChar == app)
        [self qmark];