Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Alex Atwater
Alex Atwater
2,624 Points

@property attributes

What is the difference between atomic and nonatomic and what do they do?

What about the other properties? Such as retain and release?

3 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Pasan Premaratne wrote a blog post about this that does a great job explaining some of these attributes: iOS Memory Management: The Manual-Retain-Release Model

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

Thanks Ben Jakuben! Hey Alex Atwater, in addition to the post I have up (which Ben has linked to), I'll also be publishing parts 2 and 3, which will cover strong vs weak and atomic vs nonatomic.

Hi Pasan, I'm still getting used to objective-C, coming from a C, Java and C++ background. I'm still a little fuzzy on strong, weak, copy and assign. From my understanding, copy is like final and using assign would change a property's value(s). Now, I'm still not understanding weak and strong. I get that strong keeps the object alive given that the object has a strong pointer referencing to it. But weak object will be deallocated if there is no strong pointer referencing it so will it still be deallocated if a weak object is referencing to this weak object? Also, can you expand more on a case when using non-atomic would cause data corruption on a multi-threaded environment? I guess, I'm still wrapping my mind on why cocoa touch defaults on atomic. Thank you!