29down Votefavorite12 |
I have a viewcontroller with a UITableView , the rows of which I allow to edit (delete) with a swipe-much as in the Mail app. I do it with, among other, this method: - (bool) tableview:( Uitableview *) tableview Caneditrowatindexpath :(nsindexpath *) { return Yes} /span>
However, if I has a delete button revealed, and at the same time I use back navigation of my UINavigationController , i.e. when I popViewControllerAnimated: , th E app crashes with the following message: [Viewcontroller Tableview:caneditrowatindexpath:]: Message sent to deallocated instance 0xaae64d0 How can I resolve this problem? |
Up vote57down voteaccepted |
In your view controller ' s dealloc method, set the table view's property to editing NO .
ShareEditflag |
answered Oct 8 ' at 8:41Guy Kogus 3,9681 |
|
|
this works but it is only started happening in IOS7. Any idea Why? – imran oct "at 10:49 |
|
because Apple ' s written some buggy Code. – guy Kogus Oct "at 22:50 |
|
|
hope we is all submitted Bug Reports: ) – burrows111 jan "at 13:54 |
|
at first, I thought this is a random CR Ash because of system bugs because Crashlytics tells me only few people (out of thousands) have this issue. Now I know why and get my app Fixed! – benck feb" at 9:17 |
|
Nice find. I See Apple still hasn ' t fixed this. –tander Mar at 9:32 |
|
|
Add a Comment |
Up vote35down vote |
I had the same problem, but I am using ARC and I didn ' t want to being mucking about in the Dealloc method. Doing it in Viewwilldisappear is sufficient to stop the crash. - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; [table setEditing:NO];}
ShareEditflag |
answered Oct 8 ' at 16:14Nathan Rabe 49026 |
|
|
|
is it wrong to a dealloc method un Der ARC as long as you don ' t call [Super dealloc]? – artooras Oct 9 ' at 9:27 |
|
it ' s not wrong. The accepted answer won ' t break anything and would compile normally. You literally won ' is allowed to call [Super Dealloc] or release as ARC is supposed to call them for you. My suggestion is mostly to reduce confusion since I didn ' t want a unusual dealloc method when none of my other classes H Ave One. It also feels weird to being setting a property in an object moments before it'll likely be released. – nat Han Rabe oct 9 ' at 15:39 |
this method would sometimes cause weird behaviour if you present other VCs etc so I Wou LD Use the Dealloc method. – imran oct" at 10:51 |
|
viewdiddisappear: also Works, which I prefer in this case as the User doesn ' t see the TableView transitioning out of the editing State. – defragged mar 6 ' + at 13:20 |
|
|
Thank .... I also had this issue on iOS7 only....–lepert Mar ' in 4:42 |
|
TableView crash handling of jump pages in edit state