Работы на обратном отсчет времени, когда я получаю эту ошибку при попытке запустить этот код:Swift: селектор непризнанного отправлен Instance
код ошибки: Непризнанный селектор посланного к экземпляру
class ViewController: UIViewController, UITableViewDelegate {
@IBOutlet weak var datePicker: UIDatePicker!
@IBOutlet weak var label: UILabel!
weak var timer: NSTimer?
let formatter: NSDateComponentsFormatter = {
let _formatter = NSDateComponentsFormatter()
_formatter.allowedUnits = [.Year, .Month, .Day, .Hour]
_formatter.unitsStyle = .Full
return _formatter
}()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
datePicker.date = NSDate().dateByAddingTimeInterval(1000) // initialize it to whatever you want
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
timer = NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: "didFireTimer:", userInfo: nil, repeats: true)
}
override func viewDidDisappear(animated: Bool) {
super.viewDidDisappear(animated)
timer?.invalidate()
}
func didFireTimer(timer: NSTimer) {
label.text = formatter.stringFromDate(NSDate(), toDate: datePicker.date)
}
сообщение вся ошибка:
2015-11-23 22:34:45.148 DatePicker xxTestxx[19009:4738036] -[UIView setDate:]: unrecognized selector sent to instance 0x7feaf8f9cbf0
2015-11-23 22:34:45.151 DatePicker xxTestxx[19009:4738036] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setDate:]: unrecognized selector sent to instance 0x7feaf8f9cbf0'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102e75f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104b99deb objc_exception_throw + 48
2 CoreFoundation 0x0000000102e7e56d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000102dcbeea ___forwarding___ + 970
4 CoreFoundation 0x0000000102dcba98 _CF_forwarding_prep_0 + 120
5 DatePicker xxTestxx 0x0000000102c8e944 _TFC19DatePicker_xxTestxx14ViewController11viewDidLoadfS0_FT_T_ + 260
6 DatePicker xxTestxx 0x0000000102c8e9e2 _TToFC19DatePicker_xxTestxx14ViewController11viewDidLoadfS0_FT_T_ + 34
7 UIKit 0x0000000103824cc4 -[UIViewController loadViewIfRequired] + 1198
8 UIKit 0x0000000103825013 -[UIViewController view] + 27
9 UIKit 0x00000001036fe51c -[UIWindow addRootViewControllerViewIfPossible] + 61
10 UIKit 0x00000001036fec05 -[UIWindow _setHidden:forced:] + 282
11 UIKit 0x00000001037104a5 -[UIWindow makeKeyAndVisible] + 42
12 UIKit 0x000000010368a396 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4131
13 UIKit 0x00000001036909c3 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1750
14 UIKit 0x000000010368dba3 -[UIApplication workspaceDidEndTransaction:] + 188
15 FrontBoardServices 0x0000000106a28784 -[FBSSerialQueue _performNext] + 192
16 FrontBoardServices 0x0000000106a28af2 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
17 CoreFoundation 0x0000000102da2011 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
18 CoreFoundation 0x0000000102d97f3c __CFRunLoopDoSources0 + 556
19 CoreFoundation 0x0000000102d973f3 __CFRunLoopRun + 867
20 CoreFoundation 0x0000000102d96e08 CFRunLoopRunSpecific + 488
21 UIKit 0x000000010368d4f5 -[UIApplication _run] + 402
22 UIKit 0x000000010369230d UIApplicationMain + 171
23 DatePicker xxTestxx 0x0000000102c9120d main + 109
24 libdyld.dylib 0x00000001056a192d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
его обычно, когда вы создали выход или действие, а затем пересмотрены или удалены выход/действие. Вам нужно будет удалить ссылку на выход/действие. Сделайте это в раскадровке, щелкнув правой кнопкой мыши на любых элементах, которые могут быть выгружены с помощью управляемых выходов и удалены любые неиспользуемые ссылки. –
Взгляните на мой код, это должно решить вашу проблему выбора ... Если нет, напишите мне еще раз ... –
Сообщение об ошибке * full * было бы полезно. –