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: Tue, 28 Jan 2003 11:05:11 +0100
Hi Stephane, Chris, Andrew, Philippe and Zauhar,
On Monday, Jan 20, 2003, at 17:32 Europe/Copenhagen, Stiphane Sudre
wrote:
I've been searching the net, both GNUStep, my mail and mamasam, but
I could not find specific information about how to make my object
mutable.
I've collected a few guesses, and I might be wrong in some of the
cases.
I have a stupid suggestion.
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.
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.
I finally found out how to do this stuff. It all worked like I
expected, but as I kept getting errors, I was about to give up on it.
Well, this was the only thing that stopped me from getting it working.
I was about to believe that I got all this class-hierarchy-stuff wrong,
and fall back to old C-style w/realloc.
The problem was that no matter what I did, I got "selector not
recognized", and in my code I really had the method in the class
"MyMutableExampleArray".
The thing was, I started out using a NSMutableArray for this stuff, so
I did the following in awakeFromNib:
examples = [[NSMutableArray alloc] init];
in the header file, it looks like this:
MyMutableExampleArray *example;
-Ofcourse it helped when I changed the above line to...
examples = [[MyMutableExampleArray alloc] init];
-Now I got no problems getting this array stuff working, and I have it
as a mutable array for objects that do not inherit from NSObject or
NSProxy.
I'd like to thank you for your help.
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.