What are “strong” and “weak” references? Why are they important and how can they be used to help control memory management and avoid memory leaks?



What are “strong” and “weak” references? Why are they important and how can ..

Answer / Manish Kumar

In Objective-C, strong and weak references are used for managing object memory. A strong reference increases the retain count of an object, preventing it from being deallocated until there are no more strong references. Weak references do not increase the retain count of an object and allow the object to be deallocated when it has no strong references or any other weak references pointing to it. By using weak references, you can prevent circular references that would cause memory leaks. You can use weak references to make sure that your code does not maintain strong references to objects that are owned by another object or a view controller, which may be deallocated before your own object.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Apple iOS Interview Questions

What is the use of double question marks (“??”) ?

1 Answers  


What is the 'interface' and 'implementation'?

1 Answers  


Arc is compile time or run time feature?

1 Answers  


what does @synthesize do?

1 Answers  


What is UIApplication?

1 Answers  


Will iphone 6s get ios 14?

1 Answers  


What is nslayoutanchor?

1 Answers  


Explain the usage of struct?

1 Answers  


What is dynamic typing in iOS operating system?

1 Answers   CDC,


Difference between coredata & sqlite?

1 Answers  


what is the difference between bounds and frame?

1 Answers  


What's fast enumeration?

2 Answers  


Categories