Kelly
Kelly

Reputation: 11

Simulator crashes when launching in xcode and the issue is in view.controller.init

I've been teaching myself Swift and only a few days in. I've honestly done very little to the code and not sure what is going on. I cannot find a similar thread on stackoverflow with the same issue.

This is all I have written so far in the ViewController.swift:

import 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
        }
    }


}

When I try launching the simulator, the simulator crashes and gives me this code within 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 claims that the breakpoint is at "0x10b542b10 <+16>: movq $0x0, -0x18(%rbp)". I am not sure what any of this means nor how to fix it.

I tried to "undo" all the code I changed in my Main.storyboard, but even when I do that, the code that once worked does not work anymore either and produces the same error, so I am wondering if it is an issue with xCode itself (restarting does not help either).

Any help would be greatly appreciated! Thank you so much!

Upvotes: 1

Views: 493

Answers (1)

Sverrisson
Sverrisson

Reputation: 18167

Did you connect the @IBOutlet weak var calcNum to your label on the view. I.e. is the circle next to it filled? If not connect them, by dragging a line from the circle to the label.

Upvotes: 1

Related Questions