I don't argue with that - I got the idea from the Todo sample code which is 
shamelessly copied.

https://github.com/couchbaselabs/ToDoLite-iOS/blob/master/ToDoLite/Profile.m 
Line 46

Just for my own understanding can you see a fundamental difference between this 
sample code and what we are doing? I am just curious...again I don't need to 
repeat myself that we had a major brain fart when uninitializing the database 
object and causing the whole blowup but still...

Thanks as always
Christoph

From: Jens Alfke <[email protected]<mailto:[email protected]>>
Reply-To: 
"[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Date: Monday, November 10, 2014 at 2:31 PM
To: 
"[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: Re: Assertion failure in CBLModel.m:461

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 a topic in the Google 
Groups "Couchbase Mobile" group.
To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/mobile-couchbase/xvJOvcRtQnI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to 
[email protected]<mailto:[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<https://groups.google.com/d/msgid/mobile-couchbase/DBF3A05E-8C6D-4141-A9A4-6466C999AA9A%40couchbase.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/D0867D5A.18EAE%25cberlin%40christophberlin.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to