objective c - When does retain count for an autoreleased object decrement? -


if have autoreleased object, when retain count (i.e. value returned when call method retaincount on it) decrement? had figured when scope of method object allocated within ended, tests aren't indicating that. have code following:

int itemindex = 0; nsarray* items = [mresponse componentsseparatedbystring:@","];   self.mtext = (nsstring*)[items objectatindex:itemindex++]; self.mtext = [mtext gtm_stringbyunescapingfromurlargument]; nslog(@"retain count: %d",[mtext retaincount]); 

this returns 2 count (mtext has retain property makes sense), , after exiting method, call outside likewise returns 2.

don't @ retaincount. it's misleading. long follow memory management programming guide you'll fine.

if rephrase question "when default autorelease pool drain?" answer when control flow returns runloop.


Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -