Может кто-нибудь объяснить, почему в последней строке выводится -1? Это происходит, когда copy вызывается для NSMutableString, я ожидаю, что returnCount strFour будет равен 1, поскольку должна быть возвращена неизменная копия.
NSMutableString *str =[NSMutableString stringWithString:@"hi"];
NSLog(@"new instantiated variable has a retain cout:");
NSLog(@"%d",[str retainCount]); //1, str is a pointer, its value is a memory address
NSMutableString *strFour =[str copy]; //receiver str is mutable, copy returns an immutable
NSLog(@"%d",[strFour retainCount]); ////strFour s retain count should be 1, but it had a retain count of -1
Большое спасибо.