NSArray/MutableArray subclass/extension
NSArray/MutableArray subclass/extension
- Subject: NSArray/MutableArray subclass/extension
- From: Ben Dougall <email@hidden>
- Date: Mon, 20 Oct 2003 01:21:59 +0100
hiyer,
i'm trying to make, but am not even sure what form it should take, a
single extension/wrapper or something of both the NSMutableArray and
NSArray classes to give my code that uses it a single, very simple
(simple from the use of it point-of-view) initWith method that returns
an appropriate object. the goal is to be able to get back simply from a
single initWith:(id)someThings call an object that has been
appropriately decided on by the class in question and also populated
appropriately - the 'appropriately' decisions based entirely on
someThings that's passed in the int parameter, made by the class that
this question is about.
for example if string points to an NSString instance, and ???? = what
this question is asking about :
???? *x = [[???? alloc] initWith:string];
that'd leave x pointing to the extension/wrapper/whatever. say, in the
above case, because it was a string, the string is split up in a
particular way and the end result makes use of an NSArray. and..
???? *x = [[???? alloc] initWith:anArrayOfThings];
because that was an array passed to the init method the new array gets
populated in a particular way and what's returned makes use of an
NSMutableArray.
the point is, depending on what is passed in initWith i want to have
that method make decisions and be able to return an instance that
contains/wraps/extends either an NSArray or NSMutableArray set up in
various ways, again based on what was passed in initWith.
also the returned object needs to have some extra methods of its own so
can not be just a straight normal array or mutable array.
i've grappled with several things, so far which i haven't had much luck
with. i tried 'composite objects' (which subclass the abstract class
and passes most method calls straight on) as described on the bottom of
apple's class clusters page, and catagories - i'm not saying i think
those two ways are necessarily wrong for this (or right), i'm just
saying i couldn't get either of them to work. any ideas how that should
be done? (i'm very much set on one single init method that makes
decisions and returns all the various types).
thanks, ben.
_______________________________________________
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.