iOS FAQs nsstring Direct Assignment Confusion

Source: Internet
Author: User

1. Description of the problem

A strange problem was encountered in the project in which a property title was defined in the class, whose type is nsstring and set to @property (nonatomic,retain) NSString *title;


Defines a method that modifies the property with the following code:

-(void) Getsettinginfofrmowebview: (uiwebview*) webview{    nsstring *value = [WebView stringbyevaluatingjavascriptfromstring:@ "Document.getelementsbyname (' Column_title ') [0].value];        [Self settitle:value];    title = value;}

When using title = value to assign a value directly, the content of title is messed up (the value of the title's retaincount is 1);

When you use [self settitle:value] to assign a value, the content of the title is correct (the value of the title's Retaincount is 2).


2. What are the differences between the two ways of assignment? Why is the content of title changed when it is assigned directly?



iOS FAQs nsstring Direct Assignment Confusion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.