Re: How do I create a mutable version of my object?
Re: How do I create a mutable version of my object?
- Subject: Re: How do I create a mutable version of my object?
- From: Jens Bauer <email@hidden>
- Date: Mon, 20 Jan 2003 20:15:44 +0100
Hi Stephane,
On Monday, Jan 20, 2003, at 17:32 Europe/Copenhagen, Stiphane Sudre
wrote:
On Monday, January 20, 2003, at 05:29 PM, Jens Bauer wrote:
On Monday, Jan 20, 2003, at 12:38 Europe/Copenhagen, Stiphane Sudre
wrote:
Make your MyExampleArray use a NSMutableArray of MyExample objects
and don't allow adding/removing objects with methods from
MyExampleArray but add some in the MyMutableExampleArray.
Doesn't this require me to add objects of type NSObject?
MyExample is a subclass of NSObject.
I'm afraid of the overhead of NSObject. If it contains too many
instance-variables, then it'll quickly grow huge. On the other hand, if
NSObject already knows how to "repeat" a subclass (which I think might
be difficult for NSObject), it would only add the overhead once.
The thing is, that I may want to have 2 floats or 2 shorts in my
subclass, but make large arrays with this object. One extra pointer per
object would be acceptable, but 16 bytes would be too much I think.
In fact, that was my first approach, then I discarded it, probably
because I saw how NSString and NSArray did it. ;)
Yes, also because:
I think I will get in trouble, when creating a MyMutableExampleArray,
and then passing it as parameter to a method that takes a
MyExampleArray, won't I ?
I don't think since MyMutableExampleArray would be subclass of
MyExampleArray. MyMutableExampleArray has just more methods.
How do I implement/enable addObject (just an example) then ?
-Should I do that this way...
@interface MyMutableExampleArray (MyExtendedMutableExampleArray)
- (void)addObject:(id)anObject;
@end
...??
-And can I recycle the NSMutableArray code for this?
Love,
Jens
_______________________________________________
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.