IOS filtered tableview navigation push UIView, then UIView back causing crash

advertisements

Did someone meet the same bothering issue? I cannot figure out the UIView will send release message to whom.

Many thanks for any advice.

My test code Strictly follow Apple tableView/Search example code guide. Initial TableView works perfect. and the filtered tableView is triggered to display in UISearchController -> searchResultsController, code is like below.

func updateSearchResultsForSearchController(searchController: UISearchController) {

...

        let tableController = self.searchController!.searchResultsController as! FilteredTableViewController
        tableController.datasource = self.tableData?.tableFilteredCellRecords
        tableController.navController = self.navigationController
        tableController.tableView.reloadData()
...
}

In the filtered tableView, Cell row display OK, then click any cell to trigger detail UIView display, code is like below:

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {

    let record = self.tableData!.getFilteredTableRecord(indexPath.row)

    if(record != nil) {
        let detailViewController = DetailViewController()
        detailViewController.titleText = record?.title
        detailViewController.descText = record?.desc
        detailViewController.imgExist = record!.imgview

    self.navigationController?.pushViewController(detailViewController, animated: false)

    }
}

Then the detail UIView display well, but when click 'Back' button to return TableView, the App crash.

After enable Zombie, the debug report:

(lldb)
Optional("A server with the specified hostname could not be found.")
2015-05-04 22:45:31.687 Swift_UI_programmatically[2057:419330] *** -[UIViewControllerWrapperView release]: message sent to deallocated instance 0x7fdefe0d8250
(lldb) 

0x102db5f49 <+489>:  callq  *0x3062a1(%rip)           ; (void *)0x0000000102b08000: objc_msgSend
0x102db5f4f <+495>:  jmp    0x102db5f72               ; <+530>
0x102db5f51 <+497>:  movq   %r14, %rdi
0x102db5f54 <+500>:  callq  0x102eaff58               ; symbol stub for: object_getClassName
0x102db5f59 <+505>:  movq   %rax, %rcx
0x102db5f5c <+508>:  leaq   0x32cabd(%rip), %rsi      ; @"*** NSForwarding: warning: object %p of class '%s' does not implement forwardInvocation: -- dropping message"
0x102db5f63 <+515>:  movl   $0x4, %edi
0x102db5f68 <+520>:  xorl   %eax, %eax
0x102db5f6a <+522>:  movq   %r14, %rdx
0x102db5f6d <+525>:  callq  0x102dfd000               ; CFLog
0x102db5f72 <+530>:  movq   0x34b0a7(%rip), %rax      ; NSInvocation._retainedArgs
0x102db5f79 <+537>:  cmpb   $0x0, (%rbx,%rax)
0x102db5f7d <+541>:  je     0x102db5fb1               ; <+593>
0x102db5f7f <+543>:  movq   (%r13), %rax
0x102db5f83 <+547>:  testb  $-0x80, 0x22(%rax)
0x102db5f87 <+551>:  je     0x102db5fb1               ; <+593>
0x102db5f89 <+553>:  movq   0x34b080(%rip), %rcx      ; NSInvocation._frame
0x102db5f90 <+560>:  movq   (%rbx,%rcx), %rcx
0x102db5f94 <+564>:  movl   0x1c(%rax), %edx
0x102db5f97 <+567>:  movzbl 0x20(%rax), %esi
0x102db5f9b <+571>:  addq   %rdx, %rsi
0x102db5f9e <+574>:  movq   (%r15,%rsi), %rdi
0x102db5fa2 <+578>:  movq   (%rcx,%rsi), %rsi
0x102db5fa6 <+582>:  movq   (%rax), %rax
0x102db5fa9 <+585>:  movl   0x10(%rax), %edx
0x102db5fac <+588>:  callq  0x102eb04b0               ; symbol stub for: memmove
0x102db5fb1 <+593>:  movq   0x34b050(%rip), %rax      ; NSInvocation._retdata
0x102db5fb8 <+600>:  movq   (%rbx,%rax), %r15
0x102db5fbc <+604>:  movq   0x34a02d(%rip), %rsi      ; "methodReturnType"
0x102db5fc3 <+611>:  movq   %r12, %rdi
0x102db5fc6 <+614>:  callq  *0x306224(%rip)           ; (void *)0x0000000102b08000: objc_msgSend
0x102db5fcc <+620>:  movzbl (%rax), %eax
0x102db5fcf <+623>:  cmpl   $0x44, %eax
0x102db5fd2 <+626>:  jne    0x102db6009               ; <+681>
0x102db5fd4 <+628>:  fldt   (%r15)
0x102db5fd7 <+631>:  jmp    0x102db6009               ; <+681>
0x102db5fd9 <+633>:  movq   %rax, %rbx
0x102db5fdc <+636>:  movq   %rbx, %rdi
0x102db5fdf <+639>:  callq  0x102e60560               ; getAtomTarget
0x102db5fe4 <+644>:  movq   %rax, %r12
0x102db5fe7 <+647>:  movq   %r12, (%r15,%r14)
0x102db5feb <+651>:  movl   $0x400, %ecx
0x102db5ff0 <+656>:  xorl   %r8d, %r8d
0x102db5ff3 <+659>:  movq   %r13, %rdi
0x102db5ff6 <+662>:  movq   %r15, %rsi
0x102db5ff9 <+665>:  movq   %r15, %rdx
0x102db5ffc <+668>:  callq  0x102d4ed60               ; __invoking___
0x102db6001 <+673>:  cmpq   %r12, (%r15)
0x102db6004 <+676>:  jne    0x102db6009               ; <+681>
0x102db6006 <+678>:  movq   %rbx, (%r15)
0x102db6009 <+681>:  movq   %r15, %rax
0x102db600c <+684>:  addq   $0x18, %rsp
0x102db6010 <+688>:  popq   %rbx
0x102db6011 <+689>:  popq   %r12
0x102db6013 <+691>:  popq   %r13
0x102db6015 <+693>:  popq   %r14
0x102db6017 <+695>:  popq   %r15
0x102db6019 <+697>:  popq   %rbp
0x102db601a <+698>:  retq
0x102db601b <+699>:  leaq   0x35638e(%rip), %rax      ; __CFOASafe
0x102db6022 <+706>:  cmpb   $0x0, (%rax)
0x102db6025 <+709>:  je     0x102db603b               ; <+731>
0x102db6027 <+711>:  movl   $0x15, %edi
0x102db602c <+716>:  xorl   %edx, %edx
0x102db602e <+718>:  xorl   %ecx, %ecx
0x102db6030 <+720>:  xorl   %r8d, %r8d
0x102db6033 <+723>:  movq   %r13, %rsi
0x102db6036 <+726>:  callq  0x102e30880               ; __CFRecordAllocationEvent
0x102db603b <+731>:  addq   $0xa, %rbx
0x102db603f <+735>:  movq   -0x30(%rbp), %rdi
0x102db6043 <+739>:  callq  0x102eaff76               ; symbol stub for: sel_getName
0x102db6048 <+744>:  movq   %rax, %rcx
0x102db604b <+747>:  leaq   0x32c90e(%rip), %rdx      ; @"*** -[%s %s]: message sent to deallocated instance %p"
0x102db6052 <+754>:  movl   $0x3, %edi
0x102db6057 <+759>:  xorl   %eax, %eax
0x102db6059 <+761>:  movq   %rdx, %rsi
0x102db605c <+764>:  movq   %rbx, %rdx
0x102db605f <+767>:  movq   %r13, %r8
0x102db6062 <+770>:  callq  0x102dfd000               ; CFLog
0x102db6067 <+775>:  int3
->  0x102db6068 <+776>:  jmp    0x102db6167               ; <+1031>

0x102db606d <+781>:  movq   %r12, %rdi


Try this

   self.view = [[UIView alloc]initWithFrame:self.view.frame];

when changed viewController..