我收到此错误,我不知道为什么?
我今天开始学习敏捷
2016-06-28 02:40:03.393 Calculator[7072:173608] -[Calculator.ViewController touchDigit]: unrecognized selector sent to instance 0x7fc4a9465000
2016-06-28 02:40:03.400 Calculator[7072:173608] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Calculator.ViewController touchDigit]: unrecognized selector sent to instance 0x7fc4a9465000'
*** First throw call stack:
(
0 CoreFoundation 0x0000000100c40e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000102980deb objc_exception_throw + 48
2 CoreFoundation 0x0000000100c4948d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000100b9690a ___forwarding___ + 970
4 CoreFoundation 0x0000000100b964b8 _CF_forwarding_prep_0 + 120
5 UIKit 0x000000010145f194 -[UIApplication sendAction:to:from:forEvent:] + 92
6 UIKit 0x00000001015ce6fc -[UIControl sendAction:to:forEvent:] + 67
7 UIKit 0x00000001015ce9c8 -[UIControl _sendActionsForEvents:withEvent:] + 311
8 UIKit 0x00000001015cdaf8 -[UIControl touchesEnded:withEvent:] + 601
9 UIKit 0x00000001014ce49b -[UIWindow _sendTouchesForEvent:] + 835
10 UIKit 0x00000001014cf1d0 -[UIWindow sendEvent:] + 865
11 UIKit 0x000000010147db66 -[UIApplication sendEvent:] + 263
12 UIKit 0x0000000101457d97 _UIApplicationHandleEventQueue + 6844
13 CoreFoundation 0x0000000100b6ca31 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
14 CoreFoundation 0x0000000100b6295c __CFRunLoopDoSources0 + 556
15 CoreFoundation 0x0000000100b61e13 __CFRunLoopRun + 867
16 CoreFoundation 0x0000000100b61828 CFRunLoopRunSpecific + 488
17 GraphicsServices 0x0000000105256ad2 GSEventRunModal + 161
18 UIKit 0x000000010145d610 UIApplicationMain + 171
19 Calculator 0x0000000100a6361d main + 109
20 libdyld.dylib 0x000000010348992d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
我的主班只有这种简单的方法,不知道发生了什么
import UIKit
internal class ViewController : UIViewController {
@IBAction internal func touchDigit(sender: UIButton)
}
谢谢
最佳答案
尝试在情节提要/ xib中解除绑定操作,然后重新绑定。
我猜测是基于错误中缺少的:
(由于有参数,它应该是[ViewController touchDigit:]
),因此您在情节提要中设置了参数sender
后就添加了它。
我只是自己测试了一下,重新绑定时,情节提要板将其显示为touchDigitWithSender
,即使它保留了名称touchDigit
。可能是一些奇怪的Swift / Objective-C互操作性问题。
附言internal
是默认的访问说明符,您不必将其添加到每个声明中