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

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -