I have a problem on the memory management of a tableviewcell (exc_bad_access).
One of mine tableviewcell include a uiwebview that loads asynchronous html data (loadHTMLString method) and the current controller is set as its delegate.
When i pop tableviewcontroller from my navigation controller too fast the app crashes.
In my opinion this is the reason why it fails:
- if cell deallocs before the controller => all ok, delegate is still live and i can even set its delegate to nil in its own dealloc method
- if cell deallocs after the controller (i guess because table view cells are autoreleased) => the app crashes because its delegate it's still set to the deallocated controller
Any idea how to correctly solve this?? Thank you..
CODE in cellForRowAtIndexPath:
...
CustomTableViewCell * cCell = (CustomTableViewCell*)cell;
cCell.myWebView.delegate = self;
[[cCell myWebView] loadHTMLString:html baseURL:baseURL];
....
dealloc, i'm sure autoreleased cell is deallocated before the controller. - A-Live