On 28 Mar 2010, at 18:40, Michael Davey wrote:

1. Some other piece of code assigns a new value to 'myFields' without releasing the old value.

That is the only part of my code that adds values to the field.

In order to handle your fields instance variable correctly, what do you think about the following:

Create fields in the init method of your "MyClass" object (I don't know how you call this class):

fields  = [[NSMutableDictionary alloc] init];

by which you retain the fields dictionary.

And destroy fields in the corresponding dealloc method:

[fields release];
fields = nil;

If you want to use the fields dictionary anywhere in your code, you just do only calls like:

[fields addObject: ...];
[fields removeObject: ...];
MyOtherObject *myOtherObject = [fields objectWithKey: ...];
etc.

but you do *not* invoke methods which initialize or dealloc the fields object.

Klaus

_______________________________________________

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 arch...@mail-archive.com

Reply via email to