Re: Copying Notification Dictonaries & sortingUsingSelector problems
Re: Copying Notification Dictonaries & sortingUsingSelector problems
- Subject: Re: Copying Notification Dictonaries & sortingUsingSelector problems
- From: <email@hidden>
- Date: Wed, 26 Jun 2002 18:05:42 +0200
- Thread-topic: Re: Copying Notification Dictonaries & sortingUsingSelector problems
Charles, Thanks! Wow, you made me learn a lot and I will certainly correct the mistakes made here. It will for sure help to make my app a little bit less leaky, I mean not leaky at all of course ;-)
Just a few more questions, if I may,
You asked:
>
Second, what type is docMenuItemsExperiments?
>
NSMutableDictionary or
>
NSDictionary? If it is mutable, you should be using
>
-mutableCopy instead of -copy.
It is Mutable now, but the idea is that one controller object generates the items that I want to appear in the dock menu. But since the dock menu is controlled by another controllerobject, I send a notification containing the items in a dictionary.
This dictionary is then read and used to generate the dockmenu items. So I guess, since the receiver only has to read the dockmenuitems, the dictionary doesn't need to be mutable, does it? Second you wrote:
>
... it looks like you want
>
docMenuItemExperiments to hold a copy of the dictionary. If >
>
you kept JUST the object passed and the object is mutable, it
>
could change underneath you.
Would this be a good idea in this situation, just keep it since the sender object is the only one changing the contents of the dictionary? Or is it wiser and/or safer to copy the contents anyway.
Many thanks,
Alex
>
Hi everybody,
>
>
I'd like to start by thanking everyone who helped me with my "inter object messaging problem".
>
Although I realize that I should try to think of a better MVC implementation for my next app ;-), I
>
resorted to using notification and this works perfectly. Still I wonder, do I have to use the "copy"
>
command like in my code below, or is it unnecessary and therefor unwanted? Allong with the
>
notification I send along a dictionary with some properties of my "experiments". In the following way
>
I "copy" this dictionary to one within the receiving controller object:
>
>
In the init method:
>
dockMenuItemsExperiments = [[NSMutableDictionary alloc] init];
>
>
- (void)updateDockItemsExperiments: (NSNotification *)note{
>
dockMenuItemsExperiments = [[note object] copy]; // copies the dictionary
>
[self updateDockMenu]; // a method to update my dockmenu
>
}
>
>
Is this the correct way, or could I just say: dockMenuItemsExperiments = [note object]; ? Or doesn't >it matter as long as I dealloc the dockMenuItemsExperiments dictionary when I do not longer >need it?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.