Re: Collections [was NSCollectionConroller ?]
Re: Collections [was NSCollectionConroller ?]
- Subject: Re: Collections [was NSCollectionConroller ?]
- From: Ondra Cada <email@hidden>
- Date: Sun, 29 Feb 2004 10:50:29 +0100
On Saturday, Feb 28, 2004, at 19:36 Europe/Prague, T Reaves wrote:
All of these have things in common; the ability to iterate over them,
to create sub-collections from them, to combine them with other
collects, to get the contents, to determine membership, etc. This
functionality aught to be described in an NSCollection superclass.
What for? Luckily, unlike Java or C++, we happen to have a polymorphism
in ObjC: the following code works excellently for any array or set in
container, no superclass needed:
if ([container containsObject:object]) printf("It's there");
else {
printf("It's not there, but these are:");
NSEnumerator en=[container objectEnumerator];
id o;
while ((o=[en nextObject])) printf([[o description] cString]); //
okay, cString obsoleted, I know
}
Make the container mutable anything, addObject: would work just as well.
I am not sure how to reasonable define operations like sub-collections
or combinations regardless the type of the target, which IMnsHO is why
there are no such services currently; nevertheless, if you know how it
should look like, a few categories would add the services easily and
again keeping the full polymorphism.
---
Ondra Hada
OCSoftware: email@hidden
http://www.ocs.cz
private email@hidden
http://www.ocs.cz/oc
_______________________________________________
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.