Re: Newbie: Proper objc style
Re: Newbie: Proper objc style
- Subject: Re: Newbie: Proper objc style
- From: Jorge Martins <email@hidden>
- Date: Sun, 9 May 2004 23:09:39 -0400
Hi!
Wow! That's exactly what I was looking for. Thanks. As far as I
remember, last time I checked the ADC website, it was a mess. Maybe
they redid the whole thing recently. Or maybe I'm totally wrong :)
I still have a question, though.
1 - Is it good style to have a class return autoreleased instances of
NSMutableArray? Should such a method be called -arrayOfWhatever?
Kind of like a convenience constructor but in another class?
Perhaps more likely to be named something akin to
"objects{For,With}..." and return an NSArray, e.g.
Wouldn't this imply that I was just returning an existing object, and
that if the user wanted to keep it around, he or she would just
retain/release it? No big deal either way.
What I am doing though, is actually building an array and the objects
it points to from scratch and autoreleasing it.
If the user doesn't retain it, it will be expensive to build another
one. We are talking about possibly really large arrays.
I consider this difference significant because, performance wise, it's
expensive to build arrays full of objects and I want it to be obvious
that this method is actually creating the array and the objects that it
references.
That's why it thought of naming it like a convenience constructor,
except that it's not an NSArray method, it's one of my class's.
My difficulty in naming this method made me wonder if I should be doing
it at all.
Thanks.
--
Jorge Martins
email@hidden
_______________________________________________
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.