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

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -