Re: A wierd problem when enumerating a second time
Re: A wierd problem when enumerating a second time
- Subject: Re: A wierd problem when enumerating a second time
- From: David Rio Vierra <email@hidden>
- Date: Wed, 25 Dec 2002 20:53:32 -1000
Okay, nailed it.
// in -(void)generateStars: (int) number between: (NSSize) range
planet = [NSMutableDictionary dictionary];
// planet production
// ...
[[self stars] addObject: planet];
[planet release]; //BAD - _stars will soon contain a bad pointer
Since you don't alloc or retain your planet dictionary, you do not need
to release it. The stars array keeps a reference to it, not you, and
NSArray retains and releases its objects appropriately. BTW, you might
want to consider using NSRange instead of NSSize for the range, since
it contains ints instead of floats, and you don't need to cast to int
like you do currently.
- Rio
On Wednesday, December 25, 2002, at 08:28 PM, Jeffrey Drake wrote:
When I do this in an NSView subclass:
[snip]
All of this code is available at http://ezdrake.com/gx or complete
project: http://ezdrake.com/GalacticXtended.tar.gz
SpaceView.h is the main class that this code is in.
Nobody in #macdev (opn) seems to know why this might be doing this. All
accessors and mutators are properly coded as far as I have been told.
Any help would be greatly appreciated,
Jeff
_______________________________________________
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.
_______________________________________________
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.