When should I use copy instead of using retain? I didn’t quite get it.
Share
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.
You would use
copywhen you want to guarantee the state of the object.At this point b was just messed up by the 3rd line there.
In this case b is the original string, and isn’t modified by the 3rd line.
This applies for all mutable types.