Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the point of setRetainsRegisteredObjects:?

Why would I want to set that to YES? What difference would that make? Must I worry about this?

like image 378
dontWatchMyProfile Avatar asked Jun 11 '10 06:06

dontWatchMyProfile


1 Answers

setRetainsRegisteredObjects: to YES makes your context maintain a strong reference to managed objects that it would otherwise maintain a weak relationship with. When you perform a fetch request, the objects returned have a weak reference (by default) to the respective managed object context. Only when an object is modified (added, changed, deleted) does the managed object context (MOC) maintain a strong relationship to the object.

Setting setRetainsRegisteredObjects: to YES ensures that strong pointers will be maintained between all fetched objects.

I don't know what @TechZen is talking about - this can be the cause for a sneaky bug if you're not careful. It's a useful method to invoke on the MOC when you find yourself in a situation where this would be useful.

like image 51
Taylor Halliday Avatar answered Oct 17 '22 18:10

Taylor Halliday