Невозможно сохранить пользовательский ввод, не сталкиваясь с этим, отладчик говорит, что я успешно храню пользовательский ввод в моих переменных, но после запуска действия сохранения он вылетает и указывает на мой
Class App Delegate: with "Thread 1 signal SIGABRT" error
и в командной строке написано:
"libc++abi.dylib: terminating with uncaught exception of type NSException"
Вот действие сохранения
let saveAction = UIAlertAction(title: "Save", style: .default)
{ [unowned self] action in
// find textfield's text (name) guard let way to get unwrap value otherwise return early*/
guard let textField1 = alert.textFields?.first,
let nameToSave = textField1.text else
{
return
}
/*find textfield's text (size) guard let way to get unwrap value otherwise return early*/
guard let textField2 = alert.textFields?[1],
let sizeToSave = textField2.text else
{
return
}
// find textfield's text (contact) guard let way to get unwrap value otherwise return early*/
guard let textField3 = alert.textFields?[2],
let contactToSave = textField3.text else
{
return
}
guard let textField4 = alert.textFields?[3],
let preferenceToSave = textField4.text else
{
return
}
//call save method by passing info
self.save(name: nameToSave, size: Int16(sizeToSave)!, contact: Int32((contactToSave))!, seating: preferenceToSave)
self.tableView.reloadData()
}
, а вот функция сохранения, вызываемая в строке со второй по последнюю выше
func save(name: String, size: Int16, contact: Int32, seating: String ) {
guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else {
return
}
let managedContext = appDelegate.persistentContainer.viewContext
let entity = NSEntityDescription.entity(forEntityName: "Party", in: managedContext)!
let party = NSManagedObject(entity: entity,
insertInto: managedContext)
party.setValue(name, forKeyPath: "name")
party.setValue(size, forKeyPath: "size")
party.setValue(contact, forKeyPath: "contact")
party.setValue(seating, forKeyPath: "seating")
do {
try managedContext.save()
parties.append(party)
tableView.reloadData()
} catch let error as NSError {
print("Could not save. \(error), \(error.userInfo)")
}
}
Если необходимо предоставить что-то еще, что может помочь, пожалуйста, дайте мне знать
Полная командная строка:
2019-04-24 14:34:41.738429-0400 WaitUp[25353:1273717] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/alexanderhoinville/Library/Developer/CoreSimulator/Devices/5623D759-E945-4844-9D55-CE708330A41F/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2019-04-24 14:34:41.739724-0400 WaitUp[25353:1273717] [MC] Reading from private effective user settings.
2019-04-24 14:34:51.330 WaitUp[25353:1273717] *** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.7.47/UITableView.m:8174
2019-04-24 14:34:51.366 WaitUp[25353:1273717] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView (<UITableView: 0x7ff5ef835800; frame = (0 64; 375 603); clipsToBounds = YES; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x60000005fa40>; layer = <CALayer: 0x60800022b2a0>; contentOffset: {0, -64}; contentSize: {375, 44}>) failed to obtain a cell from its dataSource (<WaitUp.ViewController: 0x7ff5eec0e1d0>)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010709fb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000104242141 objc_exception_throw + 48
2 CoreFoundation 0x00000001070a3cf2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x0000000103ddc3b6 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 UIKit 0x0000000104c82fcf -[UITableView _configureCellForDisplay:forIndexPath:] + 230
5 UIKit 0x0000000104c8e7b8 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 836
6 UIKit 0x0000000104c8e9a8 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
7 UIKit 0x0000000104c632e9 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2845
8 UIKit 0x0000000104c9797c -[UITableView _performWithCachedTraitCollection:] + 111
9 UIKit 0x0000000104c7eb2a -[UITableView layoutSubviews] + 233
10 UIKit 0x0000000104be520b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1268
11 QuartzCore 0x0000000109e19904 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x0000000109e0d526 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 370
13 QuartzCore 0x0000000109e0d3a0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
14 QuartzCore 0x0000000109d9ce92 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
15 QuartzCore 0x0000000109dc9130 _ZN2CA11Transaction6commitEv + 468
16 QuartzCore 0x0000000109dc9b37 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 115
17 CoreFoundation 0x0000000107045717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
18 CoreFoundation 0x0000000107045687 __CFRunLoopDoObservers + 391
19 CoreFoundation 0x000000010702a720 __CFRunLoopRun + 1200
20 CoreFoundation 0x000000010702a016 CFRunLoopRunSpecific + 406
21 GraphicsServices 0x0000000108f5aa24 GSEventRunModal + 62
22 UIKit 0x0000000104b220d4 UIApplicationMain + 159
23 WaitUp 0x000000010383ed57 main + 55
24 libdyld.dylib 0x0000000107fd965d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)