[futurebasic] Re: [FB] Objective C - ivar dealoc from memory

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2017 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Wed, 8 Mar 2017 20:14:03 -0500
Victor wrote:

> It’s true, but i don’t have a local variable. My NSMutableArray is an instance variable, like:
> 
> --------------------------------------—
> @interface AppDelegate ()
> {
> 	NSMutableArray *mymutarr;
> }
> @end

First, thanks to Bernie for pointing out the error of my ways when I attempted to release an object in ARC. (Ingrained old-school ways, sorry.)

Reviewing Apple's Transitioning To AR Release Notes found here:

http://tinyurl.com/zlvw3lh

Note this statement under the heading "ARC Enforces New Rules" in third sentence under the first bullet:

"You do not have to (indeed you cannot) release instance variables"

I fear Victor may be attempting the impossible.

Also, I wonder about the declaration of his instance variable with ARC turned on. Shouldn't it be something like:

@interface AppDelegate ()
{
	@property NSMutableArray *mymutarr;
}
@end

or perhaps:

@interface AppDelegate ()
{
	@property (nonatomic, weak) NSMutableArray *mymutarr;  // Use weak to prevent retain cycles.
}
@end

Wouldn't it be easier to let ARC do it's job and not worry about memory management? On the other hand, you could always turn off ARC and go Old School creating, retaining, releasing instance variables at will, along with the headaches that brings.

Ken