Re: Class clusters - infinite loop?
Re: Class clusters - infinite loop?
- Subject: Re: Class clusters - infinite loop?
- From: Wade Tregaskis <email@hidden>
- Date: Mon, 27 Jun 2005 19:44:40 +1000
I can't find a single reference to the word "cluster" in any of
the Foundation documentation*.
Ahem... just tried to check NSArray docs; the very beginning (well,
2nd paragraph) of Class Description says pretty explicitly
Grrr, useless Spotlight. (yes, I've explicitly added the
documentation to /.Spotlight-V100/_rules.plist, and it does work
sometimes)
To be more specific, if I pick any typical class cluster like the
NS collections, there is no instruction as to which initialiser(s)
return self, which return a new instance, etc.
Go on: there is a specific chapter "Subclassing Notes", which,
among many other interesting details, say
"... This means that you must provide the storage for your
subclass and implement the primitive methods that directly act on
that storage."
That's my point. I was wrong about actually being able to subclass
them at all - you're right, NS collections do return self in their
initialisers (just tested NSArray & NSDictionary, as examples).
However, as that documentation states and as my quick tests show, you
can't actually use the NS collections from the subclass - e.g. trying
to call initWithObjects:forKeys:count: from an NSDictionary subclass
yields:
2005-06-27 19:30:38.494 Scratch[647] *** Uncaught exception:
<NSInvalidArgumentException> *** initialization method -
initWithObjects:forKeys:count: cannot be sent to an abstract object
of class NSDictionarySubclass: Create a concrete instance!
So yes, while you can subclass them, you have to essentially
reimplement them anyway... kinda makes subclassing pointless.
Granted, for most uses of NS collections you can get away with just
adding categories happily enough, but it's just an example; as with
the counter-example in NSStream & friends, this is a real problem.
I do agree the documentation is not perfect, but to be frank, I
don't see the slightest problem here?
Yes, I do apologise for criticising the documentation - it is
accurate enough in this case. Not obvious enough for me at a quick
glance, but, you could assume a picnic error for that one. :)
All right, in any case, I'll back off this one for a bit - I want to
do some more test cases so I can pin down my problem(s) more
precisely. I'm arguing more on the basis of having had problems in
the past, than a fresh problem at present, so as we've seen I'm not
getting the details right.
Wade Tregaskis (AIM/iChat, Yahoo & Skype: wadetregaskis, ICQ:
40056898, MSN: email@hidden, AV iChat & email:
email@hidden, Jabber: email@hidden)
-- Sed quis custodiet ipsos custodes?
_______________________________________________
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