Weird Backendless behavior and crash while working with 1 exact table in iOS app

Hello dear support team!
I am a developer of the iOS app which uses Backendless
The reason I am writing is that I faced with the issue during the development

I have 1 table in my Backendless and now I am getting crashes during the work with this table. When I try to save the object I get this crash with the reason - "[<NSConcreteValue *> valueForUndefinedKey:]: this class is not key value “coding-compliant for the key objCType”
It does not matter is the object recently created or retrieved from the table and saved again - I get this crash

I was thinking that the issue may be in the inconsistency of data between the table and the class that describes that table in the app. After checking the fields and making them consistent the crash is still happening.

Also the Backendless is acting weird on this table when I try to set new objects with relations to other tables. The pop-up with the error of duplicate fields appears and it is said that the relation is failed to set, but, after the updating of the table the new relations appear in the table’s schema. After this the real tables data begin not to appear and Backendless says that something went wrong and the new crash ticket is created. After the removal of that fields, the data begin to appear again. So. I’d assume that there is a problem with this table and its relations to other tables.

I use Backendless v5.1.0 at the moment (I’ve made a migration from v4.0.17 to 5.1.0, but this did not solve the crash)
Could you please advice how to solve the crash and this weird behavior. Thank you

Hello,

Is your project in Obj-C or Swift?

Regards,
Mark

The project is on Swift 4.2 at the moment

Do you use the “Dictionary-based” approach or the “Class-based” one to work with the data tables in Backendless? If it is class-based, do your classes have the @objcMembers annotation?

Class-based approach and yes the class includes the @objcMembers annotation

Thanks. Please provide a minimal reproducible example so we can run it on our side to see the issue.

Regards,
Mark

the object causing problems has quite a few properties so not sure I want to reproduce it all here, but the issue only occurs when trying to save. This is an object that has been in the database for a while and we can retrieve the existing data from backendless fine and work with the iOS version of the object within the app, its only when we try to save a new object to backendless or save updates to an existing object that we hit the error. None of the other objects we use are causing problems, can both save them to backendless and update them without issue.

This is the error we receive:
2018-11-14 22:57:10.707021-0600 Yeti[40514:644953] *** Terminating app due to uncaught exception ‘NSUnknownKeyException’, reason: ‘[<NSConcreteValue 0x60000256e6a0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key objCType.’
*** First throw call stack:
(
0 CoreFoundation 0x000000011205b29b _exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000110ed0735 objc_exception_throw + 48
2 CoreFoundation 0x000000011205ae09 -[NSException raise] + 9
3 Foundation 0x000000010f315fa9 -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 226
4 Foundation 0x000000010f314df1 -[NSObject(NSKeyValueCoding) valueForKey:] + 284
5 Foundation 0x000000010f3161aa -[NSObject(NSKeyValueCoding) dictionaryWithValuesForKeys:] + 157
6 Yeti 0x000000010c0a5225 -[ObjectWriter write:format:] + 496
7 Yeti 0x000000010c0a0361 -[ObjectReferenceWriter write:format:] + 371
8 Yeti 0x000000010c0b58d7 -[MessageWriter writeObject:format:] + 68
9 Yeti 0x000000010c0c1bc9 -[V3ObjectSerializer writeObject:fields:format:] + 1050
10 Yeti 0x000000010c0a5536 -[ObjectWriter write:format:] + 1281
11 Yeti 0x000000010c0a0361 -[ObjectReferenceWriter write:format:] + 371
12 Yeti 0x000000010c092816 -[ArrayWriter write:format:] + 297
13 Yeti 0x000000010c0b58d7 -[MessageWriter writeObject:format:] + 68
14 Yeti 0x000000010c0b58d7 -[MessageWriter writeObject:format:] + 68
15 Yeti 0x000000010c0c1bc9 -[V3ObjectSerializer writeObject:fields:format:] + 1050
16 Yeti 0x000000010c0a5536 -[ObjectWriter write:format:] + 1281
17 Yeti 0x000000010c0a0361 -[ObjectReferenceWriter write:format:] + 371
18 Yeti 0x000000010c092816 -[ArrayWriter write:format:] + 297
19 Yeti 0x000000010c0b58d7 -[MessageWriter writeObject:format:] + 68
20 Yeti 0x000000010c092a18 -[AMFBodyWriter write:format:] + 315
21 Yeti 0x000000010c0b58d7 -[MessageWriter writeObject:format:] + 68
22 Yeti 0x000000010c0de152 -[AMFMessageWriter write:format:] + 729
23 Yeti 0x000000010c0b58d7 -[MessageWriter writeObject:format:] + 68
24 Yeti 0x000000010c09e612 +[AMFSerializer serializeToBytes:type:] + 145
25 Yeti 0x000000010c0906dc -[HttpEngine createRequest:headers:] + 683
26 Yeti 0x000000010c0914b5 -[HttpEngine httpPostRequest:] + 514
27 Yeti 0x000000010c091e7e -[HttpEngine sendRequest:responder:] + 33
28 Yeti 0x000000010c099477 -[PersistenceService save:response:error:] + 569
29 Yeti 0x000000010bff4244 $SSo11BackendlessC4YetiE6update33_862CFA7FBD4AE8275496AACA5618D1E1LL5order4withyAC5OrderC_yypSgctF + 500
30 Yeti 0x000000010bff3cda $SSo11BackendlessC4YetiE6update_4withyAbCE9TableTypeO_yypSgctF + 586
31 Yeti 0x000000010c06cea6 $S4Yeti12OrderServiceC06updateB0_10completionyAA0B0C_yAGSg_So5FaultCSgtctF + 262
32 Yeti 0x000000010be73b66 $S4Yeti8CancelVCC17updateOrderStatusyyAA11ProgressHUDCF + 502
33 Yeti 0x000000010be73668 $S4Yeti8CancelVCC07confirmB5OrderyyFySo13UIAlertActionCcfU
+ 344
34 Yeti 0x000000010be736cd $S4Yeti8CancelVCC07confirmB5OrderyyFySo13UIAlertActionCcfU_TA + 13
35 Yeti 0x000000010be738b2 $SSo13UIAlertActionCIegg_ABIeyBy_TR + 66
36 UIKitCore 0x000000011a1884c9 -[UIAlertController _invokeHandlersForAction:] + 105
37 UIKitCore 0x000000011a188ed3 __103-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:dismissCompletion:]_block_invoke.477 + 16
38 UIKitCore 0x000000011a516347 -[UIPresentationController transitionDidFinish:] + 1325
39 UIKitCore 0x000000011a51a5f0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke.440 + 183
40 UIKitCore 0x000000011a910ed9 -[_UIViewControllerTransitionContext completeTransition:] + 102
41 UIKitCore 0x000000011a8c1fd3 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 847
42 UIKitCore 0x000000011a894ff5 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 343
43 UIKitCore 0x000000011a895635 -[UIViewAnimationState animationDidStop:finished:] + 293
44 UIKitCore 0x000000011a8956e9 -[UIViewAnimationState animationDidStop:finished:] + 473
45 QuartzCore 0x00000001106a9ed1 _ZN2CA5Layer23run_animation_callbacksEPv + 323
46 libdispatch.dylib 0x0000000112ed863e _dispatch_client_callout + 8
47 libdispatch.dylib 0x0000000112ee59d6 _dispatch_main_queue_callback_4CF + 1541
48 CoreFoundation 0x0000000111fbe7f9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
49 CoreFoundation 0x0000000111fb8e86 __CFRunLoopRun + 2342
50 CoreFoundation 0x0000000111fb8221 CFRunLoopRunSpecific + 625
51 GraphicsServices 0x000000011684e1dd GSEventRunModal + 62
52 UIKitCore 0x000000011a1b6115 UIApplicationMain + 140
53 Yeti 0x000000010c03d387 main + 71
54 libdyld.dylib 0x0000000112f4e551 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

Hello Chris,

As Mark already asked please provide a minimal reproducible example (you can attach it here or upload to Dropbox/Google Drive)

not sure I want to reproduce it all here

Please provice only the part of code that causes the issue, not all code. This issue looks weird so we need your sample to reproduce it.

Regards, Olga

I’ve found the reasons of the "[<NSConcreteValue *> valueForUndefinedKey:]: crash
There were 2 reasons:
1 - The class that was related to this table confirmed MKAnnotation protocol. There were some additional computed properties needed to make the class confirm to the protocol (btw this is strange that this caused the crash since the new properties are not stored but still). After I made a subclass of this class that is related to the table and made this subclass confirm the protocol - the issue on the saving this superclass instance disappeared.
2 - Another problem was with this subclass. Despite the instance of a subclass was force-casted to the instance of the superclass it still was the instance of that subclass, so there were inconsistency of classes and this also caused this crash. So, in order to fix the crash I was needed to create a new instance of superclass and copy the data from the subclass instance