0

Possible Duplicate:
strong / weak / retain / unsafe_unretained / assign

what's difference between unsafe_unretained and weak and assign under ARC? thanks a lot.

Community
  • 1
  • 1
CocoaUser
  • 1,361
  • 1
  • 15
  • 30

1 Answers1

0

From the documentation:

weak specifies a reference that does not keep the referenced object alive. A weak reference is set to nil when there are no strong references to the object.

Assign is identical to weak except that it does not set pointers to deallocated instances to nil, potentially leaving dangling pointers. Assign and unsafe_unretained are identical in usage.

EDIT: Oh my, it seems I massively confused property attributes and ownership qualifiers; my original answer was the correct one. Assign and unsafe_unretained are both property attributes that imply the ownership qualifier __unsafe_unretained for their backing instance variables. Use unsafe_unretained for backwards compatibility with iOS 4 and assign otherwise.

Metabble
  • 11,773
  • 1
  • 16
  • 29