在xcode中启动时模拟器崩溃,问题出在view.controller.init

时间:2015-12-31 16:25:38

标签: ios xcode swift

我一直在教自己斯威夫特,只有几天。我老老实实地对代码做的很少,不知道发生了什么。我在stackoverflow上找不到具有相同问题的类似线程。

这是我到目前为止在ViewController.swift中写的所有内容:

导入UIKit

class ViewController: UIViewController {

    @IBOutlet weak var calcNum: UILabel!

    var middleOfTyping = false

    @IBAction func numButton(sender: UIButton) {
        let digit = sender.currentTitle!

        if middleOfTyping {
            calcNum.text = calcNum.text! + digit
        } else {
            calcNum.text = digit
        }
    }


}

当我尝试启动模拟器时,模拟器崩溃并在Thread 1 - 0 ViewController.init中给出了这段代码:

    Calculator Take 2`Calculator_Take_2.ViewController.init (Calculator_Take_2.ViewController.Type)(coder : __ObjC.NSCoder) -> Swift.Optional<Calculator_Take_2.ViewController>:
    0x10b542b00 <+0>:   pushq  %rbp
    0x10b542b01 <+1>:   movq   %rsp, %rbp
    0x10b542b04 <+4>:   subq   $0x70, %rsp
    0x10b542b08 <+8>:   movq   %rdi, -0x10(%rbp)
    0x10b542b0c <+12>:  movq   %rsi, -0x8(%rbp)
->  0x10b542b10 <+16>:  movq   $0x0, -0x18(%rbp)
    0x10b542b18 <+24>:  movq   -0x18(%rbp), %rax
    0x10b542b1c <+28>:  movq   0x363d(%rip), %rcx        ; direct field offset for Calculator_Take_2.ViewController.calcNum
    0x10b542b23 <+35>:  movq   %rsi, %rdx
    0x10b542b26 <+38>:  addq   %rcx, %rdx
    0x10b542b29 <+41>:  movq   %rdi, -0x30(%rbp)
    0x10b542b2d <+45>:  movq   %rdx, %rdi
    0x10b542b30 <+48>:  movq   %rsi, -0x38(%rbp)
    0x10b542b34 <+52>:  movq   %rax, %rsi
    0x10b542b37 <+55>:  movq   %rax, -0x40(%rbp)
    0x10b542b3b <+59>:  callq  0x10b5436f8               ; symbol stub for: swift_unknownWeakInit
    0x10b542b40 <+64>:  movq   -0x40(%rbp), %rdi
    0x10b542b44 <+68>:  callq  0x10b5436e0               ; symbol stub for: swift_unknownRelease
    0x10b542b49 <+73>:  movq   0x3618(%rip), %rax        ; direct field offset for Calculator_Take_2.ViewController.middleOfTyping
    0x10b542b50 <+80>:  movq   -0x38(%rbp), %rcx
    0x10b542b54 <+84>:  movb   $0x0, (%rcx,%rax)
    0x10b542b58 <+88>:  movq   $0x0, -0x8(%rbp)
    0x10b542b60 <+96>:  movq   %rcx, -0x48(%rbp)
    0x10b542b64 <+100>: callq  0x10b542620               ; type metadata accessor for Calculator_Take_2.ViewController
    0x10b542b69 <+105>: leaq   -0x28(%rbp), %rdi
    0x10b542b6d <+109>: movq   -0x48(%rbp), %rcx
    0x10b542b71 <+113>: movq   %rcx, -0x28(%rbp)
    0x10b542b75 <+117>: movq   %rax, -0x20(%rbp)
    0x10b542b79 <+121>: movq   0x3448(%rip), %rsi        ; "initWithCoder:"
    0x10b542b80 <+128>: movq   -0x30(%rbp), %rax
    0x10b542b84 <+132>: movq   %rax, %rdx
    0x10b542b87 <+135>: callq  0x10b543692               ; symbol stub for: objc_msgSendSuper2
    0x10b542b8c <+140>: cmpq   $0x0, %rax
    0x10b542b92 <+146>: sete   %r8b
    0x10b542b96 <+150>: xorb   $0x1, %r8b
    0x10b542b9a <+154>: testb  $0x1, %r8b
    0x10b542b9e <+158>: movq   %rax, -0x50(%rbp)
    0x10b542ba2 <+162>: jne    0x10b542ba6               ; <+166> at ViewController.swift
    0x10b542ba4 <+164>: jmp    0x10b542bda               ; <+218> at ViewController.swift
    0x10b542ba6 <+166>: movq   -0x50(%rbp), %rax
    0x10b542baa <+170>: movq   %rax, -0x8(%rbp)
    0x10b542bae <+174>: movq   %rax, %rdi
    0x10b542bb1 <+177>: movq   %rax, -0x58(%rbp)
    0x10b542bb5 <+181>: callq  0x10b54369e               ; symbol stub for: objc_retain
    0x10b542bba <+186>: movq   -0x30(%rbp), %rdi
    0x10b542bbe <+190>: movq   %rax, -0x60(%rbp)
    0x10b542bc2 <+194>: callq  0x10b543698               ; symbol stub for: objc_release
    0x10b542bc7 <+199>: movq   -0x58(%rbp), %rdi
    0x10b542bcb <+203>: callq  0x10b543698               ; symbol stub for: objc_release
    0x10b542bd0 <+208>: movq   -0x58(%rbp), %rax
    0x10b542bd4 <+212>: movq   %rax, -0x68(%rbp)
    0x10b542bd8 <+216>: jmp    0x10b542bf4               ; <+244> at ViewController.swift
    0x10b542bda <+218>: movq   -0x30(%rbp), %rdi
    0x10b542bde <+222>: callq  0x10b543698               ; symbol stub for: objc_release
    0x10b542be3 <+227>: xorl   %eax, %eax
    0x10b542be5 <+229>: movl   %eax, %edi
    0x10b542be7 <+231>: callq  0x10b543698               ; symbol stub for: objc_release
    0x10b542bec <+236>: xorl   %eax, %eax
    0x10b542bee <+238>: movl   %eax, %edi
    0x10b542bf0 <+240>: movq   %rdi, -0x68(%rbp)
    0x10b542bf4 <+244>: movq   -0x68(%rbp), %rax
    0x10b542bf8 <+248>: addq   $0x70, %rsp
    0x10b542bfc <+252>: popq   %rbp
    0x10b542bfd <+253>: retq   

xcode声称断点位于&#34; 0x10b542b10&lt; + 16&gt;:movq $ 0x0,-0x18(%rbp)&#34;。我不确定这意味着什么,也不知道如何解决它。

我试图&#34;撤消&#34;我在Main.storyboard中更改的所有代码,但即使我这样做,曾经工作的代码也不再起作用并产生相同的错误,所以我想知道它是否是xCode本身的问题(重启不会帮助。)。

任何帮助将不胜感激!非常感谢你!

1 个答案:

答案 0 :(得分:1)

您是否已将@IBOutlet weak var calcNum与视图上的标签相关联。即它旁边的圆圈是填充的吗?如果没有连接它们,可以通过从圆圈拖动一条线到标签。