Oh, ok. Does that mean that the NSArray property itself should be held weak, or strong? Also, what about properties that point to NSObjects<CBLJSONEncoding>? should those be held as strong or weak?
@interface Book : CBLModel @property (strong, nonatomic) NSArray* authors; // Test to-many relationship,* is strong or weak???* @property (strong, nonatomic) id<CBLJSONEncoding> toc; // *is this strong or weak?* @end On Thursday, April 10, 2014 5:04:49 PM UTC-7, Jens Alfke wrote: > > > On Apr 10, 2014, at 3:59 PM, Ragu Vijaykumar <[email protected]<javascript:>> > 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/fb68df72-20f1-46c6-8607-03f19b02fc17%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
