On Apr 10, 2014, at 3:59 PM, Ragu Vijaykumar <[email protected]> wrote:

> I was reading the documentation and came across this note when making a 
> property refer to another CBLModel. I have no problem designating my 
> relationship weak, but if I were to make an NSArray of CBLModels (to many 
> relationship), doesn't the NSArray hold strong references to the models it 
> contains?

No, it actually uses a custom NSArray subclass (CBLModelArray) that fetches 
model objects on demand. It stores only the document IDs (as in the JSON), and 
the -objectAtIndex: method looks up and returns the document with the 
corresponding ID.

> I'm just trying to reconcile why CBLModel properties themselves should be 
> weak, but arrays of CBLModels are held strongly...

I was careful to make references to models weak because of the possibility of 
cycles, which would otherwise cause the models involved to stay in memory 
forever.

(Note that models with unsaved changes are always kept in memory until saved, 
so you'll never lose changes as a result of weak-referenced models being 
dealloced.)

--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/3DEE506B-B3B4-4BF5-A07C-A86D7447E598%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to