2

Possible Duplicate:
what is the difference between strong (in LLVM) and retain( in GCC)?

I can see everywhere that we can use strong property instead of retain in the latest object c programming. But, i want to know that how much it differs between strong and retain and what are the added advantage with strong than retain, so Apple released strong.

Thank you!

Community
  • 1
  • 1
Daisy
  • 821
  • 3
  • 12
  • 19

1 Answers1

2

Its entirely semantic (afaik) to the way ARC and non-ARC projects work. Apple would prefer everyone use ARC and is pushing in that direction.

In a non-ARC project "strong" will act as "retain". In an ARC project "retain" might work if clang doesn't flag an error (i dont use ARC), but theres a subtlety in the description.

Retain says - Im holding on to this object, until Im ready to release it, strong says (hey ARC treat this as a retained object and insert some generated code in my dealloc method to be released when the autorelease pool drains).

As far as I know thats the only difference, its conceptual and if you are in happy ARC land you should not really have to care, unless it breaks :(

deleted_user
  • 3,817
  • 1
  • 18
  • 27
  • 1
    And weak is equivalent to assign. i.e. an object reference that is not retained. If you are on a modern system, this has the added benefit of being zeroed. i.e. If you have a weak reference to an object that is deleted, then the reference will be set to `nil` so you don't need to worry about sending a message to an object that has been deallocated. – Abizern Oct 21 '12 at 11:03