1

Possible Duplicate:
Differences between strong and weak in objective-c

Let's say I have a tableview that displays a model object's data. If I declare in my UITableViewController...

@property (strong, nonatomic) NSArray *modelObject;

If I pass this array to another view controller property in a segue should it be declared weak in my destination view controller?

Community
  • 1
  • 1
mnort9
  • 1,810
  • 3
  • 30
  • 54
  • I've read the definitions multiple times, I just want to validate that I'm implementing correctly in practice. – mnort9 Dec 04 '12 at 17:08

1 Answers1

1

In this specific case, either should work.

strong is a problem if the property can hold a strong circular reference back to the referencing object. I suppose that's a possibility here but, assuming controllers aren't treated as data, not likely. Since your initiating controller is going to stay around and hold a strong reference during the lifetime of your destination controller, then having a weak property in the destination should be OK too.

One reason that I might choose strong is as insurance against problems as the app evolves. If there's any chance that the destination might someday receive its modelObject from some other source, are you going to remember that the provider must have a strong reference?

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57