Re: newbie EXC_BAD_ACCESS
Re: newbie EXC_BAD_ACCESS
- Subject: Re: newbie EXC_BAD_ACCESS
- From: Charilaos Skiadas <email@hidden>
- Date: Mon, 21 Mar 2005 19:02:33 -0600
On Mar 21, 2005, at 6:35 PM, Hamish Allan wrote:
[sd setStrokeType: type];
[sd setStrokeDesc: desc];
[self addStrokeDesc: sd]; // to add to knownStrokes array
// where addStrokeDesc retains the passed parameter sd
[sd release];
Aargh! Why have you changed the autorelease I handed you on a plate,
into a release?!
I would think that [self addStrokeDesc: sd] would presumably add sd to
some array where all those stroke descriptions are kept, hence sd would
be retained there, hence can safely be released here, since this is the
last line in the code anyway, and this method does not return sd
anyway. I don't quite see the need for the autorelease here. He is
trying to do without the class method strokeDescriptionWithType you
described (btw, I think he *should* use the class method), so it seems
to me that, while in the class method the autorelease is necessary,
here it isn't. The way Daniel is trying to implement it right now is to
have one big method that scans each row of his data, and for each row
adds the data as an item in an NSArray , each item being a
StrokeDescription. From that point of view, the moment he adds the
things in the NSArray in the addStrokeDesc method, he does not need
them afterward.)
I do think though, Daniel, that you would be better off, for
modularity, going with Hamish's suggestion of having your
StrokeDescription class implement a constructor that would return an
autoreleased object with the type and description provided, as in the
strokeDescriptionWithType, and structuring your code as he suggested.
Haris
_______________________________________________
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