Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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!