Retain Count is the term which is related to the Memory Management . whenever you create a object, Objective C doesn't really care about the object you have created , the area of memory is claimed for this object and retain count is increased by one.
YourClass *yourObj = [ YourClass alloc] init];
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
[obj someMethod];
[yourObj release];
whenever you release that object the retain count does go down by one ,whenever the retain count reaches zero, Objective C blows that object and it will be ready to reclaim that memory for another Object.
YourClass *yourObj = [ YourClass alloc] init];
[someOtherObj someMethod];
[yourObj release];
whenever you pass "yourObj" to someMethod of someOtherObj, then a retain message is passed to that object and retain count increased to two. someOtherObj will take care of reducing the retain count to one when it is done and the regular release that you made will reduce it to zero.
Here "yourObj" is the pointer variable that stores the memory address of the object (or) simply it is reference to the object. Even after the object is blown from the memory address of the memory still present in "yourObj" variable called dangling pointer but it refers to the nil object.
if you want to learn about what happens when you pass a message to nil Object, you can follow this link
YourClass *yourObj = [ YourClass alloc] init];
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
[obj someMethod];
[yourObj release];
whenever you release that object the retain count does go down by one ,whenever the retain count reaches zero, Objective C blows that object and it will be ready to reclaim that memory for another Object.
YourClass *yourObj = [ YourClass alloc] init];
[someOtherObj someMethod];
[yourObj release];
whenever you pass "yourObj" to someMethod of someOtherObj, then a retain message is passed to that object and retain count increased to two. someOtherObj will take care of reducing the retain count to one when it is done and the regular release that you made will reduce it to zero.
Here "yourObj" is the pointer variable that stores the memory address of the object (or) simply it is reference to the object. Even after the object is blown from the memory address of the memory still present in "yourObj" variable called dangling pointer but it refers to the nil object.
if you want to learn about what happens when you pass a message to nil Object, you can follow this link
Top SEO Company The best known mobile App design and development company based in Lahore Pakistan. Get applications for Android, iOS, HTML5, Windows.
ReplyDeleteIOS Apps Development in Lahore
Tripcents wouldn't exist without Youteam . Youteam Projects enabled us to rapidly develop our foundation with a product manager, lead developer, and senior designer. In just over 60 days we went from concept to Alpha. The speed, knowledge, expertise, and flexibility is second to none. Hire a Freelance Developer.
ReplyDeletewonderful concept give to here this blog..I am happy to read this concept!!
ReplyDeleteAndroid Training in Chennai | Certification | Mobile App Development Training Online | Android Training in Bangalore | Certification | Mobile App Development Training Online | Android Training in Hyderabad | Certification | Mobile App Development Training Online | Android Training in Coimbatore | Certification | Mobile App Development Training Online | Android Training in Online | Certification | Mobile App Development Training Online