Re: MutableArrays losing its contents?
Re: MutableArrays losing its contents?
- Subject: Re: MutableArrays losing its contents?
- From: Simon Stapleton <email@hidden>
- Date: Tue, 2 Dec 2003 09:14:28 +0100
Subject: Re: MutableArrays losing its contents?
Date: Mon, 1 Dec 2003 21:20:06 -0500
To: Clark Cox <email@hidden>, email@hidden
On Dec 1, 2003, at 2:16 PM, Clark Cox wrote:
Well, there you go, that's a different array (0x301650 vs. 0x33e170).
Somewhere in your code, you're assigning a new array to your pointer.
Well, your exactly right - I did some extra check and the array I'm
adding into is getting and keeping its contents its just for some
reason I'm getting a second instance of the SAME array in the other
method. But I have no idea why this is happening... My array is global
to the class and I only alloc and init it one time in my initWithFrame
method.
Well, I'd guess it's one or both of the following:
1: You say the array is global to the class - I assume you mean defined
outside of the class, rather than as an instance variable. If this is
the case, did you remember to declare it static? Otherwise you'll get
a copy for each instance of the class you instantiate.
2: You've instantiated a copy of your class in your nib, and are also
manually instantiating one in your code. In this case, you won't be
accessing the same object in your code, as follows: (I'm assuming your
class is a view, as you have an initWithFrame:)
Action that acts directly on the nib object causes the nib object to
update its contents
Action that acts indirectly goes through you windowcontroller or
similar, which has instantiated a view manually. That action sees an
empty array, as you're not looking at the same object.
My guess would be a combination of the two.
As an aside, if you're using a mutableArray in a view class, are you
sure it wouldn't be better in a model class? Obviously, I can't see
your code, but storing state in views is often a sign of borked design.
Any ideals?
Nope. No ideals, no morals, no bloody money.
simon
--
PGP Key Id : 0x50D0698D
--
Well, we finally have an indoor toilet. But what new disasters have
struck the Alpenproject?
Find out at : <
http://www.tufty.co.uk/Move/index.html>
_______________________________________________
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.