Re: newbie EXC_BAD_ACCESS
Re: newbie EXC_BAD_ACCESS
- Subject: Re: newbie EXC_BAD_ACCESS
- From: mmalcolm crawford <email@hidden>
- Date: Mon, 21 Mar 2005 00:23:06 -0800
On Mar 21, 2005, at 12:12 AM, Daniel Child wrote:
Once sigdev error was solved, I was having troubles because the
knownStrokes array was getting the last copy of sd created placed
in every single slot of the array.
Per my first reply:
"From your original listing, it looks like you're creating a single
instance of StrokeDescription and simply updating its type and
description on each iteration through the loop? Or does [self
addStrokeDesc: sd] add a copy of the StrokeDescription? What is the
implementation of addStrokeDesc:?"
(Cutting your original code down to the relevant pieces:)
// ...
StrokeDescription *sd = [[StrokeDescription alloc] init];
// ...
for (i = 0; i < 44; i++)
{
// ...
[self addStrokeDesc: sd];
} // end inner for
} // end outer for
[sd release];
}
You only created a single instance of StrokeDescription (sd), updated
its variables on each iteration, and added it to self. Assuming that
addStrokeDesc: didn't copy the StrokeDescription, then "the
knownStrokes array was" *not* :getting the last copy of sd created
placed in every single slot of the array" -- it was getting the same
object (the only one you created) at each slot in the array...
mmalc
_______________________________________________
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