Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are mixing metaphors here - you use a property but set it like an ivar - its possible that creates a leak. Also, if you release the array, you don't have to release every object as it will do that for you.</p> <p>So, use an ivar</p> <pre><code>@MyClass... { NSMutableArray *imageArray; } </code></pre> <p>Now you can set it to new arrays, and for sure the old array is released. If you want to release the array completely, just set it to nil.</p> <p>Alternately, if you want to use properties, then when you change the object, use:</p> <pre><code>self.imageArray = ...; </code></pre> <p>Now, a second problem - your code accesses imageArray directly (no leading "_") - did you synthesize the ivar using the same name? This is probably not a good idea as it just confuses people when they read your code. If you just drop the <code>@synthesize</code>, you now get the ivar "for free" as the property name with a "_" prepended. You can directly access that ivar but anyone reading your code will know its attached to a property.</p> <p>EDIT: You obviously are not releasing the objects you think you are. Your problem is quite similar to <a href="https://stackoverflow.com/a/16418823/1633251">this one</a>. What you need to do is as follows:</p> <p>1) create a UIImage subclass, and add a log statement in the dealloc. Instead of creating UIImages, you are going to create MyImages (the subclass), which means you'll need your subclass .h file anywhere you want to use it (pr put it in the pch file while debugging). Do this first to see if the images get released. If not you know your problem.</p> <p>2) Subclass NSArray (NOT NSMutableArray, not you don't really need mutable arrays in the code you show above). If there are reasons that you must use mutable arrays, then when you set the ivar, use [MyArray arrayWithArray:theMutableArray] first. Log the dealloc. </p> <p>Now run your tests. Either the array, or the images, is not getting released. Once you know which, you can track down the retain issue.</p> <p>There is an old saying, I'll butcher it, but it goes something like, when you try everything that can possible be the cause of a problem, and that doesn't fix it, then it has to be something that you assume is NOT the problem that is actually it.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload