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: Jeffrey Drake <email@hidden>
- Date: Thu, 26 Dec 2002 02:31:58 -0500
I use the NSSize because it makes sense in the code. NSRange uses
location/length, which I need a width and a height.
I thank you so much. My major difficulty with Cocoa has been the memory
management. I shall remember this so I don't do this again. It leads to
so many problems.
On a side note, I am kind of wondering about how bezier paths draw. You
may have noticed a bezier path being created for every star that would
look like a +. But when I draw it, it seems more like a few dots in a
square. It seems almost like how opengl would not quite work as
expected.
Thank you again,
Jeffrey Drake
On Thursday, December 26, 2002, at 01:53 AM, David Rio Vierra wrote:
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.
_______________________________________________
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.