swift - 执行被中断,原因: EXC_BAD_ACCESS - Swift Literals

标签 swift swift-playground

我做了一个简单的程序来测试 Swift 整数文字。我还没有深入研究 Swift。我从网页复制了代码并重命名了变量。我得到:

Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0). The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation.

import UIKit

let desimaali = 42
let binaari = 0b101010
let oktaali = 0o52
let heksa = 0x2A

我曾尝试用普通空格手动替换所有空白字符,以防有特殊的隐藏字符,但情况似乎并非如此。可能是什么问题呢? Swift Playgrounds 中的错误? (OS X 10.11.6 和 Xcode 8.2.1。)

最佳答案

我从这里找到了解决方案:Xcode 8 error when start MyPlayground. How to fix it?

在末尾添加更多行并删除这些行:

I had the same issue and tried adding an additional line to the default playground text (the code that a new playground creates by default). Same error but then I went to the end of the file, backspaced over everything up to the end of the line with var string = "Hello, playground" and hit Enter and the playground worked! Somehow forcing XCode to reread the file without a bunch of trailing blank lines fixed it? Weird.

关于swift - 执行被中断,原因: EXC_BAD_ACCESS - Swift Literals,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45223577/

相关文章:

ios - XCode 7 和 Swift 混淆

swift - 摆脱 Playground 上的额外输出

swift - 在 Swift 中使用 DispatchQueue 时出现时间差异

swift - 在 swift Playground 中使用 Type T

swift - Swift 中泛型数组的问题

ios - CoreData 对象在实体之间移动不起作用

swift - 如何显示用户在提要上发布消息的时间?

swift - NSDate timeIntervalSince1970 无法在 Swift 中工作?

ios - 从 UIImageView 派生的动态创建的控件缺少函数

swift - Struct 中的嵌套枚举,Swift 编译器错误?