在文字和标识符objective-c之外不允许使用非ASCII字符

Jay*_*bey -3 objective-c identifier literals non-ascii-characters ios

我收到一个错误,因为" 不允许在文字和标识符之外使用非ASCII字符 ".以下是代码:

- (void)purchaseMyProduct:(SKProduct *)product {

    if ([self canMakePurchases]) {
        SKPayment *payment = [SKPayment paymentWithProduct:product];
        [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
        [[SKPaymentQueue defaultQueue] addPayment:payment];
    }
    else{
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: @"Purchases are disabled in your device" message:nil delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil];

        [alertView show];
    }
}
Run Code Online (Sandbox Code Playgroud)

截图

我在else块上遇到这个错误.我试过删除空格但没有用.我哪里错了?

Gre*_*reg 5

删除包含else它的行(完全删除它,包括换行符),然后再次手动输入,然后再次清理和构建.

当您从富文本源(例如网站)复制和粘贴代码时,Xcode有时会错误处理插入空格的方式,并且插入unicode空间而不是普通空格,编译器无法识别这些空格.完全删除该行并手动重新键入它可以解决此问题,因为删除了有问题的字符.