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