Я пытаюсь создать приложение, которое сохраняет некоторые ifo, всякий раз, когда я пытаюсь получить некоторую информацию, используя coredata, она выходит из строя, я сделал несколько функций для сохранения и получения данных с использованием coredata, эта функция отвечает за получение данных:
var entity = ""
var atribute = ""
var retrieved = [""]
func retrieve(entityNm: String, atribute: String) -> Array<String>{
let request = NSFetchRequest<NSFetchRequestResult>(entityName: entityNm)
request.returnsObjectsAsFaults = false
do {
let result = try context.fetch(request)
for data in result as! [NSManagedObject] {
retrieved = retrieved+[data.value(forKey: atribute) as! String]
print(retrieved)
}
} catch {
print("Failed")
}
return retrieved
}
это предполагаемая ошибка:
2019-09-18 21:34:14.077942-0300 app[54033:2040978] -[app.ViewController reveal:]: unrecognized selector sent to instance 0x7fccbdc0e0c0
2019-09-18 21:34:14.085303-0300 app[54033:2040978] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[app.ViewController reveal:]: unrecognized selector sent to instance 0x7fccbdc0e0c0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010619c1bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010518e735 objc_exception_throw + 48
2 CoreFoundation 0x00000001061baf44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKitCore 0x0000000109c33b4a -[UIResponder doesNotRecognizeSelector:] + 287
4 CoreFoundation 0x00000001061a0ed6 ___forwarding___ + 1446
5 CoreFoundation 0x00000001061a2da8 _CF_forwarding_prep_0 + 120
6 UIKitCore 0x0000000109c06ecb -[UIApplication sendAction:to:from:forEvent:] + 83
7 UIKitCore 0x00000001096420bd -[UIControl sendAction:to:forEvent:] + 67
8 UIKitCore 0x00000001096423da -[UIControl _sendActionsForEvents:withEvent:] + 450
9 UIKitCore 0x000000010964131e -[UIControl touchesEnded:withEvent:] + 583
10 UIKitCore 0x0000000109c420a4 -[UIWindow _sendTouchesForEvent:] + 2729
11 UIKitCore 0x0000000109c437a0 -[UIWindow sendEvent:] + 4080
12 UIKitCore 0x0000000109c21394 -[UIApplication sendEvent:] + 352
13 UIKitCore 0x0000000109cf65a9 __dispatchPreprocessedEventFromEventQueue + 3054
14 UIKitCore 0x0000000109cf91cb __handleEventQueueInternal + 5948
15 CoreFoundation 0x0000000106101721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
16 CoreFoundation 0x0000000106100f93 __CFRunLoopDoSources0 + 243
17 CoreFoundation 0x00000001060fb63f __CFRunLoopRun + 1263
18 CoreFoundation 0x00000001060fae11 CFRunLoopRunSpecific + 625
19 GraphicsServices 0x000000010f3721dd GSEventRunModal + 62
20 UIKitCore 0x0000000109c0581d UIApplicationMain + 140
21 app 0x0000000104857234 main + 68
22 libdyld.dylib 0x00000001086f2575 start + 1
23 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
это функция раскрытия:
@IBAction func reveal() {
print(cmds.retrieve(entityNm: "Plants", atribute: "names"))
//print(cmds.retrieve(entityNm: "Plants", atribute: "reminders")[0])
}