3

With NSZombieEnabled set to YES, my app crashes in simulator and on the device. After profiling using Instruments, I have narrowed down the issue to the search display controller I am using:

Zombie Messaged: An Objective-C message was sent to a deallocated 'UIView' object (zombie) at address: 0x1134fb730"

Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller 16 Zombie -1 00:25.897.720 UIKit -[UISearchDisplayController _cleanUpSearchBar]

I have done a lot of research online (including searching on stack overflow) but have not been able to pinpoint the exact cause. Most people recommend setting the delegates on the search display controller to nil on viewWillDisappear and I have already tried that.

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.searchDisplayController.delegate=nil;
    self.searchDisplayController.searchBar.delegate=nil;
}

I would really appreciate any assistance or hints anybody can provide.

Andrey Gordeev
  • 30,606
  • 13
  • 135
  • 162

2 Answers2

4

Another possible reason is a bug that was apparently still lurking in iOS 7.0.x, but fixed in 7.1, described here :

https://devforums.apple.com/message/858259#858259 (Apple dev forums link - dev membership required)

It can happen if you've added the UISearchBar to the TableView's tableHeaderView (as it is shown in Apple's 'Table Search' sample), in which case a workaround is to remove it from there and tell the UISearchDisplayController to display the search bar in the status bar :

[self.searchDisplayController.searchBar removeFromSuperview];
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;

the only drawback is that this hides the table's title, but at least it doesn't crash. Upgrading to 7.1 fixed the problem for me.

Guillaume Laurent
  • 1,734
  • 14
  • 11
1

Judging by what I've read the solution depends on the characteristics of your searchDisplayController @property.

@property (nonatomic, retain) - Make sure you nil out the UISearchDisplayController in viewDidUnload:

self.searchDisplayController = nil;

@property (nonatomic, strong) - From this answer, it also appears that there may be an OS bug if you try to nil out a UISearchDisplayController if the property is strong. So instead make sure you:

  1. @synthesize searchDisplayController; in your .m file.
  2. Set searchDisplayController to be an IBOutlet.

If that doesn't work can you please post your @property declaration for searchDisplayController from your header file?

Also I don't think you'll need to nil out the search bar delegate.

Community
  • 1
  • 1
alexgophermix
  • 4,189
  • 5
  • 32
  • 59
  • thanks user740474, i believe you have solved my issue, your solution worked perfectly, really appreciate your help!!! – user3007208 Nov 19 '13 at 14:36