Where is the memory leak in my UITableViewController?

后端 未结 5 678
逝去的感伤
逝去的感伤 2021-01-27 18:00

The table view works fine however when I leave the view and come back to it the second time, I get a memory leak. Probably something in the viewDidLoad just not sure.

I

5条回答
  •  Happy的楠姐
    2021-01-27 18:40

    Please see my response here: Deallocating and removing UiButtons

    It contains an explanation of when you should retain/release or rely on autorelease. Apply these rules to your code above. In short, anytime you alloc anything, you should be following it with a call to release on that object. If you don't, you'll have a memory leak.

    Update:

    You're not releasing the activityIndicator that you create here.

    - (void)viewDidLoad {
        [super viewDidLoad];
    
        // ...
    
        activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        // ...
        [self.view addSubview:activityIndicator];
    }
    

提交回复
热议问题