WaekHashMap
WaekHashMap
- Subject: WaekHashMap
- From: Pierre Bernard <email@hidden>
- Date: Mon, 22 Aug 2005 15:09:45 +0200
Hi!
I have a NSOutlineView where I use custom views for rows. The is one instance of the view for each row, i.e. one for each business object.
Knowing the business object I need to find the view. I would thus have an NSDictionary indexed by the business object. This does not work as NSDictionary makes the very odd choice to copy keys rather than to simply retain them. NSManagedObjects don't support copying. I thus resort to indexing my dictionary with NSManagedObjectIDs. Works fine.
Now I don't want to leak memory. I would like the view to go away if the NSManagedObject is deleted. here the Java programme in me longs for a WeakHashMap, where entries go away when their key does. No such luck in absence of a garbage collector.
My first idea is to alloc and release the views in the controller methods that add/remove objects from the outline view's underlying NSTreeController. I suspect this won't work to release a view when undoing an addition.
My next - currently best - idea is to register for notifications from the NSManagedObjectContext and watch those for object deletions.
Any better ideas? Any more appropriate data structures?
TIA
Pierre Bernard
---
Spinning WebObjects or cooking up Cocoa in Switzerland?
Let me know: http://homepage.mac.com/I_love_my/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden