Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to understand Retain count
    primarykey
    data
    text
    <p>I used following link for understand the retain count.<br> <a href="https://stackoverflow.com/questions/4253787/retain-count-in-iphone">retain count in iphone</a> <br> As per that question output is :</p> <pre><code>NSString *str = [[NSString alloc] initWithFormat:@"a,b,c,d"]; NSArray *anArray =[[NSArray alloc]init]; NSLog(@"Retain count: %i", [anArray retainCount]); anArray=[str componentsSeparatedByString:@","]; NSLog(@"Retain count: %i", [anArray retainCount]); </code></pre> <p>OUTPUT<br></p> <pre><code>Retain count: 2 Retain count: 1 </code></pre> <p>When I tried this code in my example :</p> <pre><code>NSString *str = [[NSString alloc] initWithFormat:@"a,b,c,d"]; NSArray *anArray=[[NSArray alloc]init]; NSLog(@"Retain count: %i", [anArray retainCount]); anArray=[str componentsSeparatedByString:@","]; NSLog(@"Retain count: %i", [anArray retainCount]); </code></pre> <p>Then OUTPUT is </p> <pre><code>Retain count: 51 Retain count: 1 </code></pre> <p>I can't understand why the retain count of <code>NSArray</code> is 51 and after assigning value in array it becomes 1.</p> <p>I also read <br><a href="https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html" rel="nofollow noreferrer">https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/MemoryMgmt.html</a> <br><a href="http://ranga-iphone-developer.blogspot.in/2011/11/what-is-retain-count-or-reference.html" rel="nofollow noreferrer">http://ranga-iphone-developer.blogspot.in/2011/11/what-is-retain-count-or-reference.html</a> <br><a href="https://stackoverflow.com/questions/13190640/ios-about-retaincount">iOS about retainCount</a> <br> and other tutorial. but I can't understand the value of <code>Retain count: 51</code>.<br></p> <p>Pleas Help me. <br> Thank You.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload