If you ever wonder why assign is used instead of retain, when specifying a delegate, here’s the answer from stackoverflow:

“Assign is for primitive values like BOOL, NSInteger or double. For objects use retain or copy, depending on if you want to keep a reference to the original object or make a copy of it.

The only common exception is weak references, where you want to keep a pointer to an object but can’t retain it because of reference cycles. An example of this is the delegate pattern, where an object (for example a table view) keeps a pointer to its delegate. Since the delegate object retains the table view, having the table view retain the delegate would mean neither one will ever be released. A weak reference is used in this case instead. In this situation you would use assign when you create your property.”

Advertisements