Object saving crash in iOS

Hi,

I’m having a strange crash. I’m trying to save a new object (MyModelObject) in my iOS project to Backendless database. The object got saved in the database, but the iOS app crashed without any clear source of the problem. I only got this error from Xcode.

I got the code for object saving from Backendless docs. I tried MyModelObject as subclass of NSObject and BackendlessEntity, both resulted in the same error.

Error from Xcode:

Thread 1Queue : com.apple.main-thread (serial)
#0 0x0000000181d97f48 in objc_exception_throw ()
#1 0x00000001827295c0 in -[NSException raise] ()
#2 0x0000000183023f74 in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
#3 0x0000000100154548 in -[NSObject(Properties) resolveProperty:value:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Types/Types.m:556
#4 0x0000000100148734 in -[AnonymousObject setFieldsDirect:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:227
#5 0x0000000100149700 in -[AnonymousObject adapt:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:370
#6 0x000000010014c470 in -[NamedObject defaultAdapt:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:63
#7 0x000000010014c324 in -[NamedObject defaultAdapt] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:54
#8 0x000000010015cbb8 in -[BodyHolderFactory createObject:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/V3Types/BodyHolderFactory.m:27
#9 0x000000010015bd40 in -[ObjectFactories createArgumentObject:argument:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Util/ObjectFactories.m:59
#10 0x000000010015bfec in -[ObjectFactories createArgumentObjectByType:argument:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Util/ObjectFactories.m:89
#11 0x0000000100147e08 in -[AnonymousObject setFieldsDirect:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:139
#12 0x0000000100149700 in -[AnonymousObject adapt:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:370
#13 0x000000010014c470 in -[NamedObject defaultAdapt:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:63
#14 0x000000010014c324 in -[NamedObject defaultAdapt] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:54
#15 0x000000010012176c in -[HttpEngine processAsyncAMFResponse:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:237
#16 0x0000000100123e60 in __41-[HttpEngine connectionDidFinishLoading:]_block_invoke at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:599
#17 0x0000000100bd5bf0 in _dispatch_call_block_and_release ()
#18 0x0000000100bd5bb0 in _dispatch_client_callout ()
#19 0x0000000100bdb658 in _dispatch_main_queue_callback_4CF ()
#20 0x00000001826e0bb0 in CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE ()
#21 0x00000001826dea18 in __CFRunLoopRun ()
#22 0x000000018260d680 in CFRunLoopRunSpecific ()
#23 0x0000000183b1c088 in GSEventRunModal ()
#24 0x0000000187484d90 in UIApplicationMain ()
#25 0x00000001000ecd70 in main at /Users/victorchandra/Dropbox/MyProject/main.m:14
#26 0x00000001821ae8b8 in start ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0 0x0000000100be5538 in _dispatch_barrier_async_f_slow ()
#1 0x0000000100123e20 in -[HttpEngine connectionDidFinishLoading:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:598
#2 0x0000000182e926ec in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke ()
#3 0x0000000182e9267c in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] ()
#4 0x0000000182e927f0 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] ()
#5 0x0000000182cff31c in ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke ()
#6 0x0000000182dece7c in ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 ()
#7 0x0000000100bd5bb0 in _dispatch_client_callout ()
#8 0x0000000100bdf354 in _dispatch_block_invoke ()
#9 0x0000000182ceba88 in RunloopBlockContext::_invoke_block(void const*, void*) ()
#10 0x000000018260d0ac in CFArrayApplyFunction ()
#11 0x0000000182ceb96c in RunloopBlockContext::perform() ()
#12 0x0000000182ceb82c in MultiplexerSource::perform() ()
#13 0x0000000182ceb658 in MultiplexerSource::_perform(void*) ()
#14 0x00000001826e0efc in CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION ()
#15 0x00000001826e0990 in __CFRunLoopDoSources0 ()
#16 0x00000001826de690 in __CFRunLoopRun ()
#17 0x000000018260d680 in CFRunLoopRunSpecific ()
#18 0x0000000183b1c088 in GSEventRunModal ()
#19 0x0000000187484d90 in UIApplicationMain ()
#20 0x00000001000ecd70 in main at /Users/victorchandra/Dropbox/MyProject/main.m:14
#21 0x00000001821ae8b8 in start ()

Here’s my code:


// MyModelObject.h
@interface MyModelObject : NSObject
@property (nonatomic, strong) NSString *objectId;
@property (nonatomic, strong) NSDate *created;
@property (nonatomic, strong) NSDate *updated;
@end




// ViewController.m
- (void) createNewModelObject
{
    MyModelObject *newObject = [MyModelObject new];
    id<IDataStore> dataStore = [backendless.persistenceService of:[MyModelObject class]];
    [dataStore save:newObject response:^(id object)
     {
		NSLog(@"Saving success");
     } error:^(Fault *fault)
     {
		NSLog(@"Saving failed");
     }];
}


Thank you before for the help.

Victor C.

Victor,

Could you try adding at least one extra property? Right now your object does not have any data whatsoever.

Regards,
Mark

Hi Mark,

So I tried adding a property ( channel = @“Channel One” ), but the result is pretty much same

 MyModelObject *newObject = [MyModelObject new];
	[newObject setChannel:@"Channel One"];

 id<IDataStore> dataStore = [backendless.persistenceService of:[MyModelObject class]];
 [dataStore save:newObject response:^(id object)
 {
		NSLog(@"Saving success");
 } error:^(Fault *fault)
 {
		NSLog(@"Saving failed");
 }];

Result:


Thread 1Queue : com.apple.main-thread (serial)
#0	0x0000000181d97f48 in objc_exception_throw ()
#1	0x00000001827295c0 in -[NSException raise] ()
#2	0x0000000183023f74 in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
#3	0x00000001001384fc in -[NSObject(Properties) resolveProperty:value:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Types/Types.m:556
#4	0x000000010012c6e8 in -[AnonymousObject setFieldsDirect:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:227
#5	0x000000010012d6b4 in -[AnonymousObject adapt:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:370
#6	0x0000000100130424 in -[NamedObject defaultAdapt:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:63
#7	0x00000001001302d8 in -[NamedObject defaultAdapt] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:54
#8	0x0000000100140b6c in -[BodyHolderFactory createObject:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/V3Types/BodyHolderFactory.m:27
#9	0x000000010013fcf4 in -[ObjectFactories createArgumentObject:argument:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Util/ObjectFactories.m:59
#10	0x000000010013ffa0 in -[ObjectFactories createArgumentObjectByType:argument:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Util/ObjectFactories.m:89
#11	0x000000010012bdbc in -[AnonymousObject setFieldsDirect:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:139
#12	0x000000010012d6b4 in -[AnonymousObject adapt:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:370
#13	0x0000000100130424 in -[NamedObject defaultAdapt:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:63
#14	0x00000001001302d8 in -[NamedObject defaultAdapt] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:54
#15	0x0000000100105720 in -[HttpEngine processAsyncAMFResponse:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:237
#16	0x0000000100107e14 in __41-[HttpEngine connectionDidFinishLoading:]_block_invoke at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:599
#17	0x0000000100bd9bf0 in _dispatch_call_block_and_release ()
#18	0x0000000100bd9bb0 in _dispatch_client_callout ()
#19	0x0000000100bdf658 in _dispatch_main_queue_callback_4CF ()
#20	0x00000001826e0bb0 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#21	0x00000001826dea18 in __CFRunLoopRun ()
#22	0x000000018260d680 in CFRunLoopRunSpecific ()
#23	0x0000000183b1c088 in GSEventRunModal ()
#24	0x0000000187484d90 in UIApplicationMain ()
#25	0x00000001000d0c68 in main at /Users/victorchandra/Dropbox/MyProject/main.m:14
#26	0x00000001821ae8b8 in start ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0	0x0000000100be9538 in _dispatch_barrier_async_f_slow ()
#1	0x0000000100107dd4 in -[HttpEngine connectionDidFinishLoading:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:598
#2	0x0000000182e926ec in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke ()
#3	0x0000000182e9267c in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] ()
#4	0x0000000182e927f0 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] ()
#5	0x0000000182cff31c in ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke ()
#6	0x0000000182dece7c in ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 ()
#7	0x0000000100bd9bb0 in _dispatch_client_callout ()
#8	0x0000000100be3354 in _dispatch_block_invoke ()
#9	0x0000000182ceba88 in RunloopBlockContext::_invoke_block(void const*, void*) ()
#10	0x000000018260d0ac in CFArrayApplyFunction ()
#11	0x0000000182ceb96c in RunloopBlockContext::perform() ()
#12	0x0000000182ceb82c in MultiplexerSource::perform() ()
#13	0x0000000182ceb658 in MultiplexerSource::_perform(void*) ()
#14	0x00000001826e0efc in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#15	0x00000001826e0990 in __CFRunLoopDoSources0 ()
#16	0x00000001826de690 in __CFRunLoopRun ()
#17	0x000000018260d680 in CFRunLoopRunSpecific ()
#18	0x0000000183b1c088 in GSEventRunModal ()
#19	0x0000000187484d90 in UIApplicationMain ()
#20	0x00000001000d0c68 in main at /Users/victorchandra/Dropbox/MyProject/main.m:14
#21	0x00000001821ae8b8 in start ()

My table has more properties, but I only fill one of them.

How about this then: could you create a new project and go through the quick start guide from here:

https://backendless.com/mobile-developers/quick-start-guide-for-ios

Does the new project work then?

So I tried creating a new project and use the downloaded lib. It works. However, when I tried the same in my project, it crash again. I used Backendless-iOS-SDK CocoaPods before, and now I’m changing to downloaded library, just like in the quick start guide. All giving same result.

Result:


Thread 1Queue : com.apple.main-thread (serial)
#0	0x0000000181d97f48 in objc_exception_throw ()
#1	0x00000001827295c0 in -[NSException raise] ()
#2	0x0000000183023f74 in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
#3	0x0000000100267478 in -[NSObject(Properties) resolveProperty:value:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Types/Types.m:555
#4	0x000000010025b5e8 in -[AnonymousObject setFieldsDirect:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:227
#5	0x000000010025c5b4 in -[AnonymousObject adapt:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:370
#6	0x000000010025f324 in -[NamedObject defaultAdapt:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:63
#7	0x000000010025f1d8 in -[NamedObject defaultAdapt] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:54
#8	0x000000010026fae8 in -[BodyHolderFactory createObject:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/V3Types/BodyHolderFactory.m:27
#9	0x000000010026ec70 in -[ObjectFactories createArgumentObject:argument:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Util/ObjectFactories.m:59
#10	0x000000010026ef1c in -[ObjectFactories createArgumentObjectByType:argument:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Util/ObjectFactories.m:89
#11	0x000000010025acbc in -[AnonymousObject setFieldsDirect:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:139
#12	0x000000010025c5b4 in -[AnonymousObject adapt:cache:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/AnonymousObject.m:370
#13	0x000000010025f324 in -[NamedObject defaultAdapt:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:63
#14	0x000000010025f1d8 in -[NamedObject defaultAdapt] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Reader/NamedObject.m:54
#15	0x0000000100234620 in -[HttpEngine processAsyncAMFResponse:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:237
#16	0x0000000100236d14 in __41-[HttpEngine connectionDidFinishLoading:]_block_invoke at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:599
#17	0x0000000100b4dbf0 in _dispatch_call_block_and_release ()
#18	0x0000000100b4dbb0 in _dispatch_client_callout ()
#19	0x0000000100b53658 in _dispatch_main_queue_callback_4CF ()
#20	0x00000001826e0bb0 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()
#21	0x00000001826dea18 in __CFRunLoopRun ()
#22	0x000000018260d680 in CFRunLoopRunSpecific ()
#23	0x0000000183b1c088 in GSEventRunModal ()
#24	0x0000000187484d90 in UIApplicationMain ()
#25	0x000000010004f9b4 in main at /Users/victorchandra/Dropbox/MyProject/main.m:14
#26	0x00000001821ae8b8 in start ()
Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)
#0	0x0000000100b5d538 in _dispatch_barrier_async_f_slow ()
#1	0x0000000100236cd4 in -[HttpEngine connectionDidFinishLoading:] at /Users/slava/Documents/Projects/WebORBiOS/CommLibiOS/weborb/Client/HttpEngine.m:598
#2	0x0000000182e926ec in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke ()
#3	0x0000000182e9267c in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] ()
#4	0x0000000182e927f0 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] ()
#5	0x0000000182cff31c in ___ZN27URLConnectionClient_Classic26_delegate_didFinishLoadingEU13block_pointerFvvE_block_invoke ()
#6	0x0000000182dece7c in ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 ()
#7	0x0000000100b4dbb0 in _dispatch_client_callout ()
#8	0x0000000100b57354 in _dispatch_block_invoke ()
#9	0x0000000182ceba88 in RunloopBlockContext::_invoke_block(void const*, void*) ()
#10	0x000000018260d0ac in CFArrayApplyFunction ()
#11	0x0000000182ceb96c in RunloopBlockContext::perform() ()
#12	0x0000000182ceb82c in MultiplexerSource::perform() ()
#13	0x0000000182ceb658 in MultiplexerSource::_perform(void*) ()
#14	0x00000001826e0efc in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#15	0x00000001826e0910 in __CFRunLoopDoSources0 ()
#16	0x00000001826de690 in __CFRunLoopRun ()
#17	0x000000018260d680 in CFRunLoopRunSpecific ()
#18	0x0000000183b1c088 in GSEventRunModal ()
#19	0x0000000187484d90 in UIApplicationMain ()
#20	0x000000010004f9b4 in main at /Users/victorchandra/Dropbox/MyProject/main.m:14
#21	0x00000001821ae8b8 in start ()

Any idea what might went wrong?

Also, I tried cleaning the cache, derived data, delete app and even restarting my macbook. Still same result.

Clearly there is a difference between your project and the one created from scratch. There could be infinite number of differences and I cannot pin point one. Try to bring your model class into the new project and see if it works there. Compare the settings, configuration, etc.

Hi Mark,

Problem solved. Turns out it’s because I added a field named “hash” in my table. It conflicted with model superclass somehow and crashed. I deleted “hash” field and the problem is gone.

Cheers,
Victor