0

Possible Duplicate:
ios confused about strong/weak references

I am new to ios development and was reading the Stanford's Lecture Notes on delegates. Why are delegates set to be weak references instead of strong?

Community
  • 1
  • 1
lakshmen
  • 28,346
  • 66
  • 178
  • 276
  • Short Answer: To prevent retain cycles. Also there are cases where you will have a strong reference to a delegate (E.g. [`NSURLConnection`](https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSURLConnection_Class/Reference/Reference.html#//apple_ref/occ/instm/NSURLConnection/initWithRequest:delegate:)) – Joe Nov 07 '12 at 16:08
  • 2
    Because your object graph will have a circular reference (a retain cycle) and the objects referencing each other will never be deallocated. A good explanation is here: http://stackoverflow.com/q/12802396/558933 – Robotic Cat Nov 07 '12 at 16:09

0 Answers0