ios - When should we release an object if we are returning it? -


check following method:

-(nsmutablearray*)providerequestarray{     nsmutablearray* requestarray=[[nsmutablearray alloc] initwithobjects:@"mystring",nil];     return requestarray; } 

now when should requestarray released doesn't produce consequences.

return object sending autorelease message.

// initwithformat: ?? nsmutablearray* requestarray=[[nsmutablearray alloc]                               initwithformat:@"mystring"]; return [requestarray autorelease]; 

or autoreleased 1 (for instance array class method) :

nsmutablearray* requestarray= [nsmutablearray array]; return requestarray; 

check out doc here.


Comments

Popular posts from this blog

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

java - Why is BlockingQueue.take() not releasing the thread? -

jQuery Ajax Render Fragments OR Whole Page -