Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You may want to post some more information about your problem (which of the two lines crashes, what you've figured out from debugging so far, etc.) so that we can offer you some better suggestions. Without knowing which line is giving you problems, I'll hazard a guess: from the sound of it, you might have an object somewhere that's getting cleaned up by the automatic garbage collection.</p> <p>Where is the variable "data" coming from? If you're creating it in the header file as a private member variable, you might have something like:</p> <pre><code>NSSomeType *data = [NSSomeType builtInInitFunction]; </code></pre> <p>A variable initialized like this will normally be autoreleased, but you probably want to make sure that the garbage collection retains the instance of that object. Try something like:</p> <pre><code>// Objects initialized with init are retained NSSomeType *data = [[NSSomeType alloc] init]; // Objects that would normally be autoreleased can be marked as retain NSSomeType *data = [[NSSomeType builtInInitFunction] retain]; </code></pre> <p>I'm not sure how your code is structured, but be sure to add at least one release for every retain and init! I'm still pretty new to Objective-C, so it's a little bit like the blind leading the blind so take my advice with a grain of salt.</p> <p>Check out the "More on Memory Management" section of <a href="http://cocoadevcentral.com/d/learn_objectivec/" rel="nofollow noreferrer" title="Learn Objective-C">Learn Objective-C</a> for more info.</p> <p>EDIT2: Clarified example code. Thanks to Evan (comments) for the help.</p> <p>EDIT3: I agree with Brad. Consider removing the AutoRelease pool you have an handling your alloc/init/release yourself. I don't know enough about the NSURLConnection object to know this, but is your *data memory being marked as Autorelease? If so, you may need to initialize in a different way or use retain. </p> <p>Step through your code in the debugger. Figure out A) exactly which line is crashing and then B) the values of all of your variables. If you're lucky, you'll notice one is nil.</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