Anyone can explain me what this line mean ? I use to see (nonatomic,retain) it’s first time I see the “assign” keyword in:
@property (nonatomic, assign) id <IconDownloaderDelegate> delegate;
Thx for your help,
Stephane
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Building on Peter’s answer:
When you create a property, you can automatically create getter and setter methods with the
@synthesizedirective. The compiler not only creates two methodsbut also puts extra code around this to prevent multiple threads from changing the property at the same time (essentially a lock).
nonatomictells the compiler that the code does not need to be thread safe, which means less code and better performance.A setter created by the compiler with
retainwould look something like this:and is why you need to release retained properties in the
deallocmethod of your class.Since the general advice is to not retain your delegate, you use
assigninstead ofretainand the setter would look like this: