Note that there are some explanatory texts on larger screens.

plurals
  1. POBreak on EXC_BAD_ACCESS in XCode?
    text
    copied!<p>I'm new to iPhone development and XCode in general and have no idea how to begin troubleshooting an <code>EXC_BAD_ACCESS</code> signal. How can I get XCode to break at the exact line that is causing the error?</p> <hr> <p>I can't seem to get XCode to stop on the line causing the problem, but I do see the following lines in my debug console:</p> <blockquote> <p>Sun Oct 25 15:12:14 jasonsmacbook TestProject[1289] : CGContextSetStrokeColorWithColor: invalid context</p> <p>Sun Oct 25 15:12:14 jasonsmacbook TestProject[1289] : CGContextSetLineWidth: invalid context</p> <p>Sun Oct 25 15:12:14 jasonsmacbook TestProject[1289] : CGContextAddPath: invalid context</p> <p>Sun Oct 25 15:12:14 jasonsmacbook TestProject[1289] : CGContextDrawPath: invalid context</p> <p>2009-10-25 15:12:14.680 LanderTest[1289:207] *** -[CFArray objectAtIndex:]: message sent to deallocated instance 0x3c4e610</p> </blockquote> <p>Now, I am attempting to draw to the context I retrieve from <code>UIGraphicsGetCurrentContext()</code> and pass to the object that I want to draw with.</p> <hr> <p>Further trial and error debugging and I found that an <code>NSMutableArray</code> I have a property for on my class was a zombie. I went into the <code>init</code> function for the class and here's the code I was using:</p> <pre><code>if ((self = [super init])) { NSMutableArray *array = [NSMutableArray array]; self.terrainBlocks = array; [array release]; } return self; } </code></pre> <p>I removed the <code>[array release]</code> line and it no longer gives me the <code>EXC_BAD_ACCESS</code> signal, but I'm now confused about why this works. I thought that when I used the property, it automatically retained it for me, and thus I should release it from within <code>init</code> so that I don't have a leak. I'm thoroughly confused about how this works and all the guides and Stackoverflow questions I've read only confuse me more about how to set properties within my init method. There seems to be no consensus as to which way is the best.</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