Re: retain variables between classes
Re: retain variables between classes
- Subject: Re: retain variables between classes
- From: "Jay Rimalrick" <email@hidden>
- Date: Tue, 16 Dec 2003 14:38:19 -0500
I tried your suggestions but then did not work. Thanks for the ideas hopefully
they will spark something that will work here.
-j
---------- Original Message ----------------------------------
From: Matt Gillette <email@hidden>
Date: Tue, 16 Dec 2003 11:06:23 -0800
>
Hi Jay,
>
>
I think copy will be your answer, but you should look at the
>
documentation to see how it works.
>
>
[array autorelease] //I'm not sure about this part
>
array = [inArray copy]; //Copy automatically retains I think, so no
>
need to retain
>
>
>
The other thing is:
>
>
> [array release];
>
> [inArray retain];
>
>
This is wrong. You always want to retain first, then release because if
>
array = inArray you get problems. So just reverse the order:
>
>
[inArray retain];
>
[array release];
>
array = inArray;
>
>
Matt
>
>
>
On Dec 16, 2003, at 9:54 AM, Jay Rimalrick wrote:
>
>
> I have two classes MainClass and AClass
>
>
>
> AClass has a method (with data item array)
>
> -(void)setInfo: (NSMutableArray *)inArray
>
> {
>
> [array release];
>
> [inArray retain];
>
> array = inArray; // also tried array = [inArray
>
> mutableCopy]
>
> }
>
>
>
> MainClass has an AClass defined and calls this method passing in a
>
> mutable
>
> array and when i debug everything is copied fine. However when later
>
> methods and delegates are called of AClass the array it the old one
>
> that was
>
> defined in the initial init call. I checked init and it is only being
>
> called once so
>
> I am assuming that in the setInfo function I am only copying it for
>
> the duration
>
> of the method .... how can I get it to last more than the duration of
>
> the setInfo
>
> method?
>
>
>
> any ideas are greatly appreciated
>
>
>
> -j
>
>
>
>
>
>
>
>
>
>
>
> ________________________________________________________________
>
> Sent via the WebMail system at 1st.net
>
> _______________________________________________
>
> 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.
>
>
>
>
________________________________________________________________
Sent via the WebMail system at 1st.net
_______________________________________________
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.