Forum Xamarin.iOS

About cleaning the Memory

RudaRuda BRUniversity ✭✭

Dear,

I have a question about cleaning the memory. Come on.

I'm doing a menu style to facebook where the left is the menu.
And this menu is loaded for the first time with information from the web.
And I put this information in RootElement (as is private in the Controller class), already creating StyledStringElement of each item.
Then I seto list (Table) with this RootElement.
So far so perfect.
Ai do a search (which is also done on the web) and seto the Table with a new RootElement with the survey data. Only after the person cancels the search, ie have to go back to the previous RootElement (the first).
So I seto again RootElement Table with private variable in ViewController.

Except that there is error, saying it has something void.

From what I understand, it looks like it is clearing RootElement that this is private because it is no longer on the table.

Is that right? How do I work? What is the best practice here?

Posts

  • RudaRuda BRUniversity ✭✭
    public class MenuController : DialogViewController
    {
        private RootElement rootBase;
    
        public MenuController() 
            : base(UITableViewStyle.Plain, new RootElement(""))
        {
        }
    
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
    
            searchBar.SearchButtonClicked += (object sender, EventArgs e) => {
    
                String search = searchBar.Text.ToLower();
    
                RootElement root = new RootElement("");
                Section sec2 = new Section();
    
        // Here is the web search and returns the data and create a list of StyledStringElement
                sec2.AddAll(...);
    
                root.Add(sec2);
    
                Root = root;
    
                searchBar.ResignFirstResponder();
            };
    
            searchBar.ShowsCancelButton = true;
    
            searchBar.CancelButtonClicked += (object sender, EventArgs e) => {
    
                Root = rootBase;
            };
    
    
    
            rootBase = new RootElement("");
            Section sec = new Section("Default");
    
            // Here is the first web search with the information standards and also created the StyledStringElement and adding the list.
            sec.AddAll(...);
    
            rootBase.Add(sec);
    
            Root = rootBase;
        }
    }
    
Sign In or Register to comment.