How do I replace weak references when using ARC and targeting iOS 4.0?

To target the older OS, you can use unsafe_unretained instead of weak in your property declaration, and it should mostly work the same way. weak references nil themselves when their target goes away, but unsafe_unretained leaves open the possibility that the object you’re linking to could turn into a dangling pointer when it is deallocated. The latter is the same behavior as if you had used assign as a property declaration in manual memory management.

You do this to avoid retain cycles, which I mention in my answer here. You don’t want to have a strong pointer to something that might have a strong pointer back to the original object. Then nothing would get released properly.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)