Your code is calling -initWithDocument: with a nil document, which is illegal. 
That initializer doesn't throw an exception, because there's a valid situation 
internally where it can be called with nil, but when you do it, the model is 
left in an illegal state.

I think I should remove -initWithDocument: from the public API 
<https://github.com/couchbase/couchbase-lite-ios/issues/521>  The reason it's 
there is so you can hook into the initialization and set up your own instance 
variables, but I can add a new public method to override, to do that in a safer 
and easier to understand way.

In general, you shouldn't initialize a model object with an -init-type method 
like your -initCurrentUserProfileInDatabase:. Instead you should call 
+modelForDocument:. The basic reason is that there can only be one CBLModel 
instance for a document at a time, and if you could initialize them by calling 
-initWithDocument:, it would be possible to create two with the same document.

—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/DBF3A05E-8C6D-4141-A9A4-6466C999AA9A%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to