Bill,

On Mar 2, 2008, at 5:35 PM, Ben Trumbull wrote:
 My question is, why would changing a property value cause another
 property to have its retain count increase?

No idea. Why don't you run it in gdb and break on the -retain method and get some stack traces ? This works best if the class you're debugging (in this case the value window controller) has a custom retain/release method that you can break on instead of NSObject's etc. If it doesn't, you can trivially make one by adding a category on it and putting -retain/-
 release/-autorelease methods on it that simply call super.

Good idea.  Here's the stack trace:
#0 0x000029aa in -[NSWindowController(MainWindow) retain] at MainWindowController.m:35 #1 0x92dfa378 in -[NSManagedObject(_NSInternalMethods) _newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:]
#2      0x92dfa250 in -[NSManagedObject(_NSInternalMethods) _allProperties]
#3 0x92dfa185 in -[NSManagedObjectContext(_NSInternalChangeProcessing) _establishEventSnapshotsForObject:]
#4      0x92dfd516 in _PFFastMOCObjectWillChange
#5      0x92dfb4e3 in -[NSManagedObject willChangeValueForKey:]
#6      0x00021a6c in -[Window setOpenAtLaunch:] at Window.m:117

Not sure what to make of it, nor why setting the property openAtLaunch increments the retain count for the window controller property.

At a low level, what's going on is that you're dirtying a managed object and Core Data is taking a snapshot of the previous state for this user event. The snapshot supports undo, rollback, and the merge policies, among other odds and ends. This snapshot may be pushed onto the undo stack, or simply kept around until you -save:, -rollback, or -reset the NSManagedObjectContext

At a high level, you've created a retain cycle between the M & V layers of the MVC pattern.

After some thought, it seems a bit weird to make the NSWindowController an attribute of a managed object. Technically, you could solve this problem by making it an unmodeled property (ivar). However, this is probably a symptom of a larger design issue.
--

-Ben
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to