Finding a view and subview for didReceiveMemoryWarning

Discussion in 'iOS Development' started by NolesFans, Dec 21, 2008.

  1. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    This type of stuffs get overlooked so it would be a potential leaks.

    We do have

    Code:
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
        // Release anything that's not essential, such as cached data
    } 
    If your apps received that warnings, it be useful to find which views that needs to be released so you can poke around of it.

    Code:
    - (void)didReceiveMemoryWarning
    {
      // use this to look at view (without creating an instance with self.view)
      NSLog(@"didReceiveMemoryWarning: view = %@, superview = %@", [self valueForKey:@"_view"], [[self valueForKey:@"_view"] superview]);
    
      [super didReceiveMemoryWarning];
    } 
    I did noticed UITableView has a views and superviews. I hope this can be useful for you.

Share This Page