0

I am new to Objective-c.I want to know the retain count of the following objects and also I would like to know the process also how it is working. I studied so many documents and watched tutorials also but this doubt remains me like that only.

NSString *str1=@"Hai";
NSString *str2=str1;
NSSstring *str3=[str2 copy];

What is the retain count of that "three strings"?

Sorry for my horrible English. Can anyone please tell me the answer. Thanks

  • 2
    Welcome to stackoverflow. Please use the search feature first. This is not the first time this has been asked and you will now receive a whole batch of downvotes and flippant links to [http://whentouseretaincount.com](http://whentouseretaincount.com). – trojanfoe Mar 24 '15 at 09:30

1 Answers1

0
NSString *str1=@"Hai";
NSString *str2=str1;
NSSstring *str3=[str2 copy];

NSLog(@"COUNT %lu",(unsigned long)[str1 retainCount]);
NSLog(@"COUNT %lu",(unsigned long)[str2 retainCount]);
NSLog(@"COUNT %lu",(unsigned long)[str3 retainCount]);
Shahab Qureshi
  • 952
  • 1
  • 7
  • 19