###やりたいこと
CoreDataをsend_data関数内で更新したいです。
参考:https://itlog.unknown-r.com/48
swift
1// MARK: -DetailViewControllerクラスからのデータの遷移 2 3 func send_data(data: cell_check) { 4 title_changer_checker = data 5 6 /**検索条件のDATE情報の取得とnilデータの排除**/ 7 let object = fetchedResultsController.object(at: cell_row_num!) 8 let Date_DATA = object.day 9 if (Date_DATA == nil) { 10 return 11 } 12 /**検索条件のDATE情報の取得とnilデータの排除**/ 13 // 読み込むエンティティを指定 14 let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "Past_Data") 15 //条件指定 16 fetchRequest.predicate = NSPredicate(format: "day == %@", Date_DATA! as CVarArg) 17 18 do { 19 if managedObjectContext == nil { 20 return 21 } 22 23 let myResult = try managedObjectContext!.fetch(fetchRequest) 24 25 let mydata = myResult[0] 26 27 mydata.setValue(data, forKey: "enum_CellCheck") 28 // ↑ここでエラー 29 30 try managedObjectContext!.save() 31 } catch { 32 print("ERROR") 33 } 34 } 35 36}
###「↑ここでエラー」の時のALL Outputの内容
*** First throw call stack:
(
0 CoreFoundation 0x0000000102570e6e __exceptionPreprocess + 350
1 libobjc.A.dylib 0x0000000101daa9b2 objc_exception_throw + 48
2 CoreData 0x0000000101e5fa9b _PFManagedObject_coerceValueForKeyWithDescription + 2357
3 CoreData 0x0000000101e40b4e _sharedIMPL_setvfk_core + 173
4 study 0x00000001014a18bb $s5study20MasterViewControllerC9send_data0F0yAA10cell_checkO_tF + 2811
5 study 0x00000001014a35fb $s5study20MasterViewControllerCAA13send_any_dataA2aDP0e1_G00G0yAA10cell_checkO_tFTW + 43
6 study 0x00000001014ad636 $s5study20DetailViewControllerC14data_send_funcyyF + 486
7 study 0x00000001014ad3d1 $s5study20DetailViewControllerC10check_ans46senderySo8UIButtonC_tF + 5313
8 study 0x00000001014ad424 $s5study20DetailViewControllerC10check_ans46senderySo8UIButtonC_tFTo + 68
9 UIKitCore 0x0000000108663c1d -[UIApplication sendAction:to:from:forEvent:] + 83
10 UIKitCore 0x0000000108012baa -[UIControl sendAction:to:forEvent:] + 223
11 UIKitCore 0x0000000108012ef2 -[UIControl _sendActionsForEvents:withEvent:] + 396
12 UIKitCore 0x0000000108011e63 -[UIControl touchesEnded:withEvent:] + 497
13 UIKitCore 0x000000010869f508 -[UIWindow _sendTouchesForEvent:] + 1359
14 UIKitCore 0x00000001086a128d -[UIWindow sendEvent:] + 4501
15 UIKitCore 0x000000010867b6d1 -[UIApplication sendEvent:] + 356
16 UIKitCore 0x00000001087064ce __dispatchPreprocessedEventFromEventQueue + 7628
17 UIKitCore 0x0000000108709692 __handleEventQueueInternal + 6584
18 UIKitCore 0x00000001086fff35 __handleHIDEventFetcherDrain + 88
19 CoreFoundation 0x00000001024d4c91 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
20 CoreFoundation 0x00000001024d4bbc __CFRunLoopDoSource0 + 76
21 CoreFoundation 0x00000001024d4394 __CFRunLoopDoSources0 + 180
22 CoreFoundation 0x00000001024cef8e __CFRunLoopRun + 974
23 CoreFoundation 0x00000001024ce8a4 CFRunLoopRunSpecific + 404
24 GraphicsServices 0x000000010cdd3bbe GSEventRunModal + 139
25 UIKitCore 0x0000000108662968 UIApplicationMain + 1605
26 study 0x00000001014a50db main + 75
27 libdyld.dylib 0x00000001050d91fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。