Whats the difference between this:
@property (nonatomic, weak) id <SubClassDelegate> delegate;
and this:
@property (nonatomic, assign) id <SubClassDelegate> delegate;
I want to use property for delegates.
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.
The only difference between
weakandassignis that if the object aweakproperty points to is deallocated, then the value of theweakpointer will be set tonil, so that you never run the risk of accessing garbage. If you useassign, that won’t happen, so if the object gets deallocated from under you and you try to access it, you will access garbage.For Objective-C objects, if you’re in an environment where you can use
weak, then you should use it.