Objective C property attributes

I have a background in .NET, but am new to iOS development (objective C).

What is the meaning of the strong vs. weak attributes of properties as in:

@property(strong) NSString *make;
@property(weak) NSString *make;
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I also do a little in .Net and do not think there is an equivalent.

In most cases I think people use a strong reference. This means that you want to "own" the object you are referencing with this property/variable. When compiled (assuming you are using ARC) any object that you assign to this property should not be destroyed providing you or some other object points to it with a strong reference. The object gets destroyed once it is set to nil (unless one or more other objects also hold a strong reference to it).

For a weak reference you signify that you don't want to have control over the object's lifetime. This kind of object only stays alive because at least one other object holds a strong reference to it. Once that is no longer the case, the object gets destroyed and your weak property will automatically get set to nil. The most frequent use cases of weak references in iOS are for delegates (to avoid retain cycles) and subviews because these have a main view controller that should hold a reference to the subview strongly.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Swift Programming

From novice to tech pro — start learning today.