Ошибка: -[Handsome_Fuel.AddVehicle superview]: unrecognized selector sent to instance 0x7fcb55c1dc30
Вот полное сообщение об ошибке:
2019-10-29 15:46:55.442464-0400 Handsome Fuel[8417:104074] -[Handsome_Fuel.AddVehicle superview]: unrecognized selector sent to instance 0x7f9f5bd33440
2019-10-29 15:46:55.449755-0400 Handsome Fuel[8417:104074] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Handsome_Fuel.AddVehicle superview]: unrecognized selector sent to instance 0x7f9f5bd33440'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23baa1ee __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50864b20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23bcb154 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x00007fff475a6e79 -[UIResponder doesNotRecognizeSelector:] + 302
4 CoreFoundation 0x00007fff23baef6c ___forwarding___ + 1436
5 CoreFoundation 0x00007fff23bb10f8 _CF_forwarding_prep_0 + 120
6 UIKitCore 0x00007fff47a4b796 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 142
7 UIKitCore 0x00007fff477038d7 -[UITableViewCell _addSubview:positioned:relativeTo:] + 402
8 UIKitCore 0x00007fff47a1f625 -[UIView initWithCoder:] + 1131
9 UIKitCore 0x00007fff477045f3 -[UITableViewCell initWithCoder:] + 85
10 Handsome Fuel 0x00000001089ee885 $s13Handsome_Fuel11VehicleCellC5coderACSgSo7NSCoderC_tcfc + 341
11 Handsome Fuel 0x00000001089ee963 $s13Handsome_Fuel11VehicleCellC5coderACSgSo7NSCoderC_tcfcTo + 51
12 UIKitCore 0x00007fff471e7350 -[UIClassSwapper initWithCoder:] + 2427
13 UIFoundation 0x00007fff46a37cd6 UINibDecoderDecodeObjectForValue + 744
14 UIFoundation 0x00007fff46a379e1 -[UINibDecoder decodeObjectForKey:] + 251
15 UIKitCore 0x00007fff471eb657 -[UIRuntimeConnection initWithCoder:] + 125
16 UIFoundation 0x00007fff46a37cd6 UINibDecoderDecodeObjectForValue + 744
17 UIFoundation 0x00007fff46a37f7d UINibDecoderDecodeObjectForValue + 1423
18 UIFoundation 0x00007fff46a379e1 -[UINibDecoder decodeObjectForKey:] + 251
19 UIKitCore 0x00007fff471e641e -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 450
20 UIKitCore 0x00007fff471e918d -[UINib instantiateWithOwner:options:] + 1145
21 UIKitCore 0x00007fff4775ec7d -[UITableView _dequeueReusableViewOfType:withIdentifier:] + 610
22 Handsome Fuel 0x00000001089e62d5 $s13Handsome_Fuel10AddVehicleC9tableView_12cellForRowAtSo07UITableF4CellCSo0kF0C_10Foundation9IndexPathVtF + 709
23 Handsome Fuel 0x00000001089e65d5 $s13Handsome_Fuel10AddVehicleC9tableView_12cellForRowAtSo07UITableF4CellCSo0kF0C_10Foundation9IndexPathVtFTo + 165
24 UIKitCore 0x00007fff47778d93 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 781
25 UIKitCore 0x00007fff4774210c -[UITableView _updateVisibleCellsNow:] + 3081
26 UIKitCore 0x00007fff477621df -[UITableView layoutSubviews] + 194
27 UIKitCore 0x00007fff47a52ad5 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2478
28 QuartzCore 0x00007fff2b06e91d -[CALayer layoutSublayers] + 255
29 QuartzCore 0x00007fff2b073323 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 517
30 QuartzCore 0x00007fff2b07fa7c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 80
31 QuartzCore 0x00007fff2afc6e54 _ZN2CA7Context18commit_transactionEPNS_11TransactionEd + 324
32 QuartzCore 0x00007fff2affc32f _ZN2CA11Transaction6commitEv + 643
33 UIKitCore 0x00007fff475723b4 _UIApplicationFlushRunLoopCATransactionIfTooLate + 104
34 UIKitCore 0x00007fff47614cba __handleEventQueueInternal + 6902
35 CoreFoundation 0x00007fff23b0d271 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
36 CoreFoundation 0x00007fff23b0d19c __CFRunLoopDoSource0 + 76
37 CoreFoundation 0x00007fff23b0c974 __CFRunLoopDoSources0 + 180
38 CoreFoundation 0x00007fff23b0767f __CFRunLoopRun + 1263
39 CoreFoundation 0x00007fff23b06e66 CFRunLoopRunSpecific + 438
40 GraphicsServices 0x00007fff38346bb0 GSEventRunModal + 65
41 UIKitCore 0x00007fff47578dd0 UIApplicationMain + 1621
42 Handsome Fuel 0x00000001089ef27b main + 75
43 libdyld.dylib 0x00007fff516ecd29 start + 1
44 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Я получаю эту ошибку только при установке равным self делегата tableView и источника данных и выполнении этой функциив ViewDidLoad () примерно так:
func SetTableViewDelegates() {
tableView.delegate = self
tableView.datasource = self
}
Это также происходит, когда я удаляю эту функцию и делаю то же самое, связывая делегат и источник данных с основным ViewController через раскадровку.
Я решил, что это то, что вызывает это. После удаления я могу открыть эту вкладку, как обычно, без сбоев. Я чувствую, что это может быть как-то связано с существованием View между основным ViewController и tableView, но я не уверен.
У меня есть расширение моего класса ViewController, которое включает в себя такие протоколы DataSource и TableViewDelegate, как это:
extension AddVehicle: UITableViewDataSource, UITableViewDelegate {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return vehicles.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let vehicle = vehicles[indexPath.row]
print(vehicles[indexPath.row])
let cell = tableView.dequeueReusableCell(withIdentifier: "vehicleCell") as! VehicleCell
cell.SetVehicle(vehicle: vehicle)
return cell
}
}
Я очень внимательно следил за этим руководством, просто меняя исходные данные. Все идет хорошо, пока часть, где источник данных и делегат назначены, и я не знаю, где еще искать.