xcode 在 Swift 源代码中发现不可打印的 ASCII 字符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39329041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 09:12:30  来源:igfitidea点击:

Unprintable ASCII character found in Swift Source Code

swiftxcode

提问by Abhi

enter image description here

在此处输入图片说明

Hi, I am new to Swift language , can anyone explain why there is error with PI Symbol here.

嗨,我是 Swift 语言的新手,谁能解释为什么这里的 PI 符号有错误。

import Foundation

class CalculatorBrain
{

    private var accumulator = 0.0

    func setOperand(operand : Double) {
        accumulator = operand
    }

    func performOperations (symbol: String) {
        switch symbol {
            case "π" :
                accumulator = M_PI
            case "√" :
                accumulator = sqrt(accumulator)
            default : break
        }
    }

    var result : Double {
        get{
            return accumulator
        }
    }
}

reference https://youtu.be/j50mPzDMWVQ?t=2303

参考 https://youtu.be/j50mPzDMWVQ?t=2303

回答by gnasher729

In Xcode: "Editor" menu, "Show Invisibles". That will show you invisible characters in your source code.

在 Xcode 中:“编辑器”菜单,“显示隐形”。这将在您的源代码中显示不可见的字符。

回答by Krishna Vivekananda

This answer is for the people who are using windows keyboard with mac system.

这个答案适用于在 mac 系统上使用 windows 键盘的人。

While typing you might have unknowingly clicked the right clickkey in your keyboard, which will create the Unprintable ASCII character that is causing the Unprintable ASCII character found in source fileerror.

键入时,您可能在不知不觉中单击了键盘上的右键单击键,这将创建无法打印的 ASCII 字符,从而导致在源文件中发现无法打印的 ASCII 字符错误。

To check this go to find and click the right clickkey and you can find them in your class and delete those characters and the error will be gone.

要检查这一点,请查找并单击右键单击键,您可以在班级中找到它们并删除这些字符,错误就会消失。

Thanks

谢谢