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? I'm just trying to reconcile why CBLModel properties themselves should be weak, but arrays of CBLModels are held strongly...
For example, you might have documents for blog comments and each blog comment has a post property whose value is the document ID of the blog post it refers to. You can model that like this: @class BlogPost; @interface BlogComment : CBLModel@property (assign) BlogPost* post;@end In the implementation of BlogComment you declare the property as @dynamic, like any other model property. Note that the declaration uses (assign) instead of the more typical (retain). This is because a relationship to another model doesn’t retain it to avoid creating reference-loops that can lead to memory leaks. Couchbase Lite takes care of reloading the destination model if necessary when you access the property. Also, Couchbase Lite does not deallocate models with unsaved changes. Thanks, Ragu -- 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/8f403de3-4352-4104-bc04-4d7c1170b69f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
