Why are Objective-C delegates usually given the property assign instead of retain?

来源:互联网 发布:永久禁止程序访问网络 编辑:程序博客网 时间:2024/05/01 10:22

A creates B A sets itself as B's delegate … A is released by its owner

If B had retained A, A wouldn't be released, as B owns A, thus A's dealloc would never get called, causing both A and B to leak.

You shouldn't worry about A going away b/c it owns B and thus gets rid of it in dealloc.