Why has NSNumber such strange retainCounts?

后端 未结 5 597
星月不相逢
星月不相逢 2020-11-28 16:36
NSNumber* n = [[NSNumber alloc] initWithInt:100];
NSNumber* n1 = n;

In the code above, why is the value of n\'s retainCount set to 2? In the second

5条回答
  •  迷失自我
    2020-11-28 17:16

    I think you have something else going on...

        NSNumber* n = [[NSNumber alloc] initWithInt:100]; 
        NSNumber* n1 = n;
        NSLog(@"n = %i",[n retainCount]);
    

    Result is 1

提交回复
热议问题