【问题标题】:iPhone - comparing a character returned by characterAtIndex with another hard coded oneiPhone - 将 characterAtIndex 返回的字符与另一个硬编码的字符进行比较
【发布时间】:2011-03-09 20:44:54
【问题描述】:

我想将 characterAtIndex 返回的字符与一些“硬”字符进行比较,例如 @" " 或 @"P"。这可能看起来很愚蠢,但我找不到这样做的方法......

【问题讨论】:

    标签: iphone comparison character hardcode


    【解决方案1】:

    使用单引号:

    if ([@"test" characterAtIndex:1] == 'e')
    

    【讨论】:

    • @Oliver 如果您仍然需要它 [yourString appendString:[NSString stringWithFormat:@"%c", character]]; 会将字符附加到字符串的末尾.
    猜你喜欢
    • 2014-09-18
    • 1970-01-01
    • 2020-09-03
    • 2014-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-20
    相关资源
    最近更新 更多