Ok I spent some more time on this and I think I found the issue…

As you hinted we DO NOT call -initWithDocument outside the subclass 
initializers. The issue occurs when trying to call the document initializer 
itself…see below:

When the database is nil, the initial document is nil as well

CBLDocument *doc = [db documentWithID:[@"profile:" stringByAppendingString
:user_id]];

But it doesn’t fail…then when we call initwithDocument and when trying to 
set the first property It blows up.

Success with properly initialized database:

<https://lh6.googleusercontent.com/-NtBLGzx7G70/VGE4Z_YRLdI/AAAAAAAAzcs/CVoIhzhbtuE/s1600/success.png>


Failure with database is nil:

<https://lh3.googleusercontent.com/-b07T2T4DI68/VGE4jD11r6I/AAAAAAAAzc0/8QN03eYUctg/s1600/failure.png>


As soon as the debugger steps forward we get this error:

*2014-11-10 14:11:43.322 OnePlan[30062:712261] *** Assertion failure in 
-[OPUserProfile setValue:ofProperty:], 
/Users/jenkins/jenkins/workspace/build_cblite_ios_102-enterprise/couchbase-lite-ios/Source/API/CBLModel.m:461*




On Monday, November 10, 2014 10:42:09 AM UTC-8, Jens Alfke wrote:
>
>
> > On Nov 10, 2014, at 9:35 AM, Christoph Berlin <[email protected] 
> <javascript:>> wrote: 
> > 
> >  Its a really stupid mistake, especially because we should check whether 
> the database actually got created but the error message also threw us off. 
>
> So your database reference is nil, and presumably when you looked up a 
> document you got nil. But how did you create the model object? 
> +modelForDocument: will immediately trigger an assertion failure if the 
> document is nil, and -initWithNewDocumentInDatabase: also fails if database 
> is nil. 
>
> The only way that I can see to create a CBLModel without a document is to 
> call -initWithDocument: nil … but you should never call that yourself. The 
> docs say "Do not call directly except from subclass initializers; to create 
> a new instance call +modelForDocument: instead." 
>
> —Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/344b2ae0-082c-480d-aaa1-a8781db443a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to