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 21:01:38 -0600
On Mar 21, 2005, at 8:03 PM, Daniel Child wrote:
Hi,
I'm not disagreeing with his approach. His four lines of code were
equivalent to my 20 or 25—and had the distinct advantage of actually
working!—but until I am so used to the idiom that I can write
extremely dense code like his, it might be good to break things up a
bit.
Sorry, I didn't mean that you were disagreeing with Hamish's approach.
The thing that I was suggesting you do, and that's the one that Hamish
also points out, and it has nothing to do with class methods, is that
instead of doing:
sd=[[StrokeDescription alloc] init];
[sd setDesc:desc];
[sd setType:type];
[self addStrokeDesc:sd];
[sd release];
Is that you create a better init method for sd, and have:
sd=[[StrokeDescripition alloc] initWithDesc:desc andType:type];
[self addStrokeDesc:sd];
[sd release];
It is more convenient to put all the necessary variables on your init,
and hide all the set.. in there, instead of having them all around the
place. It is a question of distributing the responsibilities to the
right place.
Then Hamish takes this one step further, by using the convenience
method instead of the init, since you never needed to keep sd anyway,
just wanted to pass it to the addStrokeDesc method. The rest is packing
the code more tightly, but that's not my particular cup of tea.
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