An issue where the value of a variable disappears after binding TableView in iOS

Source: Internet
Author: User

Well, the title of the most popular statement named, estimated that Baidu included, when we find the time will be more convenient.

iOS novice, this problem really debugging for a long time!

As a result of the start of large projects, but also do not have time from the foundation, I believe that most of the small company developers are this model. So many problems arise from very basic mistakes.

The project uses the MVC structure, after reading the data asynchronously, the data of the model in Nsarray is lost, the professional point is that the memory is released, and only the memory address is left.

Maybe everyone's situation is different from mine, so the solution is not necessarily the same.

The Project Server is an ASP. WebService, which uses afnetworking to read the data type XML, and then uses Gdataxmlnode to read the values in the XML to the new model, thus generating the nsarray of the model.

When the model is established, the parameter value of the property is set to

// Publisher name

@property(nonatomic,assign)nsstring *sendername;

Note that it is assign, OK, this way of building properties is to copy other code.

The problem is here, the property set assign, is the address reference, then after the call Gdataxmlnode, NSString is automatically freed, so in the Viewcontroller will not read the value.

You only need to modify the assign to copy.


// Publisher name

@property(nonatomic,retain)nsstring *sendername;


This is a very basic error, without understanding the memory release mechanism and properties of the case, to solve the problem is quite tricky, the following list this part of the basics, while doing learning it!

Introduction to @property Properties in iOS development: http://gaoyong.diandian.com/post/2011-11-02/6444165




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.