swift Uilable错误线程1断点2.4

时间:2014-08-23 05:04:11

标签: ios swift uilabel iboutlet xcode6-beta6

var lastnumber: String = ""
@IBOutlet var anserField : UILabel                           Thread 1: breakpoint 2.4
@IBOutlet var operatorLable: UILabel
override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

@IBAction func buttonTapped(TheButton: UIButton) {
    if anserField.text == "0" {
        anserField.text = TheButton.titleLabel.text
    } else {
    anserField.text = anserField.text + TheButton.titleLabel.text
    }
    println(TheButton.titleLabel.text);
}

@IBAction func plusTapped(TheButton: UIButton) {
 println("plus tapped")
    if operatorLable.text == "" {
        operatorLable.text = "+"
        lastnumber = anserField.text
        anserField.text = "0"
    }else {
        enterTapped(nil)
        operatorLable.text = "+"
    }
}

@IBAction func minusTapped(TheButton: UIButton) {
    println("minus tapped")
    if operatorLable.text == "" {
        operatorLable.text = "-"
        lastnumber = anserField.text
        anserField.text = "0"
    }else {
    enterTapped(nil)
        operatorLable.text = "-"
    }
}
@IBAction func cleartapped(AnyObject) {
anserField.text = "0"
    operatorLable.text = ""
    lastnumber = ""
 }

@IBAction func enterTapped(AnyObject?) {
    var num1 = lastnumber.toInt()
    var num2 = anserField.text.toInt()
    if !num1 || !num2 {
    ShowError()
        return
    }
    var anser = 0
    if operatorLable.text == "-" {
   anser = num1! - num2!
    } else if operatorLable.text == "+" {
       anser = num1! + num2!
    } else {
ShowError()
return

    }
    println(anser)
}
func ShowError(){
// to do this
    println("there was a error")
}

}

我需要帮助我是新来的swift和编码,我不是上帝说实话我无法弄清楚什么是不会用我的代码请帮忙! (错误在右上方看右边) 我正在编写一个计算器(不知道是否有帮助,但为什么不呢)这是一个错误,我无法修复我已经尝试了很多东西,但没有一个工作它是{{{{{ 1}}此代码来自iPhone 5sviewcontroler这是解码器和自我的东西,如果它们有用

swift

如果您还需要其他任何东西来解决问题,请填写评论

当我关闭断点并按下某些按钮时,这就是hapend (评论中的更多信息)

2014-08-22 23:39:05.613 calculater [6307:2641435] - [_ TtC10calculater14ViewController plusTapped:]:无法识别的选择器发送到实例0x7faad9dbd150 2014-08-22 23:39:05.617 calculater [6307:2641435] *由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [_ TtC10calculater14ViewController plusTapped:]:无法识别的选择器发送到实例0x7faad9dbd150' * 第一次抛出调用堆栈: (     0 CoreFoundation 0x00000001070f5055 exceptionPreprocess + 165     1 libobjc.A.dylib 0x0000000108bafa1c objc_exception_throw + 45     2 CoreFoundation 0x00000001070fbf1d - [NSObject(NSObject)doesNotRecognizeSelector:] + 205     3 CoreFoundation 0x0000000107054dbc ___ forwarding _ + 988     4 CoreFoundation 0x0000000107054958 _CF_forwarding_prep_0 + 120     5 UIKit 0x0000000107974196 - [UIApplication sendAction:to:from:forEvent:] + 75     6 UIKit 0x0000000107a78c80 - [UIControl _sendActionsForEvents:withEvent:] + 467     7 UIKit 0x0000000107a7804f - [UIControl touchesEnded:withEvent:] + 522     8 UIKit 0x00000001079b9368 - [UIWindow _sendTouchesForEvent:] + 735     9 UIKit 0x00000001079b9c93 - [UIWindow sendEvent:] + 683     10 UIKit 0x0000000107986f51 - [UIApplication sendEvent:] + 246     11 UIKit 0x0000000107993ec6 _UIApplicationHandleEventFromQueueEvent + 17699     12 UIKit 0x000000010796fcd9 _UIApplicationHandleEventQueue + 1967     13 CoreFoundation 0x000000010702b0b1 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17     14 CoreFoundation 0x000000010702099d __CFRunLoopDoSources0 + 269     15 CoreFoundation 0x000000010701ffd4 __CFRunLoopRun + 868     16 CoreFoundation 0x000000010701fa06 CFRunLoopRunSpecific + 470     17 GraphicsServices 0x000000010adbeabf GSEventRunModal + 161     18 UIKit 0x0000000107972cf8 UIApplicationMain + 1282     19计算器0x0000000106c7f6ed top_level_code + 77     20计算器0x0000000106c7f72a main + 42     21 libdyld.dylib 0x0000000109120145 start + 1 ) libc ++ abi.dylib:以NSException类型的未捕获异常终止 (lldb)

0 个答案:

没有答案