0

After add a object to NSMutableArray got reference count +2 ?

E2post *post = [E2post new];
[postsObjectArray addObject:post]
NSLog(@"RC post = %ld",CFGetRetainCount((__bridge CFTypeRef)(postsObjectArray[0])));
Cœur
  • 37,241
  • 25
  • 195
  • 267
Moosa
  • 89
  • 1
  • 8
  • NSLog show: RC post = 3 – Moosa Oct 03 '16 at 12:35
  • 1
    http://stackoverflow.com/questions/5784084/calling-retaincount-considered-harmful – Kreiri Oct 03 '16 at 13:00
  • Do you have any problem with that? It's system information, how I know apple do not recommend to use it property. By the way I have different behavior, NSLog show RC post = 2. – Gralex Oct 03 '16 at 13:08
  • The retain count is useless (which is why -retainCount was removed in ARC). CGGetRetainCount doesn't make it any more useful. – bbum Oct 03 '16 at 18:08
  • The absolute retain count at any given moment is not really useful information. However, in this case I believe it is because ARC is retaining the object before it's passed in to `CFGetRetainCount()`. But perhaps bbum will correct me. – jscs Oct 03 '16 at 18:08

0 Answers0