Best IOS Memory management @ Function Call With Returning allocated object -


I have work with return type (NSArray / NSData / NSString / NSDictionary and so on) I can come back and I can also use it, but my problem arises to release the object. Please guide me what is the best way to manage the memory for the returned object. If anything is wrong then please note and give your best solution

I refrared apple memory management guide

a)

  - (NSDT *) Certain Functions 2 {NSDT * Data = [[[NSData Allock] Inte] AutoCare]; // nsdata Fill out the content for return data; } - (zero) some tasks {NSDT * data = [some associated with self 2]; // Usage Data}   

But the advice of most blogs to avoid AutoCalues ​​is because I am using the following type

B)

  - (NSDT *) Certain Functions 2 {NSDT * Data = [[NSDTA Elok] Init]; // nsdata Fill out the content for return data; } - (zero) some functions {NSDT * data = [[self-resolution 2] is maintained); // usage data [data release]; }   

c)

  - (NSDT *) Some tasks 2 {NSDT * data = [[[NSDT allocon]]]]]]]; // nsdata Fill out the content for return data; } - (zero) some functions {NSDT * data = [[self-resolution 2] is maintained); // usage data [data release]; }   

Edit: One more thing if I try to pass the same allocated object to some function call arguments or custom deliyat object, where I want to release, what function call Or to maintain the function in DIF and then release.

  NSDT * data = [[NSDT alloca] INIT]; [Self-fictional: data];   

or

  NSDT * data = [[NSDITA ALLOCK] INIT]; [Delegate mydelegatefunction: data]; - (zero) SomfunctionCall: (NSDT *) data {NSDT * new data = [retaining data]; // data usage [data release];}   

thanks in advance

The best practice is that if the method has alloc, init, new or retained , then the method returns a maintained object, and if it does not A autoresaled object is returning, I will suggest:

  - New data {NSDT * data = [[NSDITA ALLOCK] IIT]; // nsdata Fill out the content for return data; }   

so that you can do this later:

  - (zero) some tasks {NSDT * data = [new new data]; // usage data [data release]; }    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -