当我启用“僵尸对象”时,我收到此错误(“ViewController respondsToSelector:]: message sent to deallocated instance”)。我发现错误在哪里,但我不知道如何解决它。
这是代码: ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UISearchDisplayDelegate, UISearchBarDelegate>{
// The saved state of the search UI if a memory warning removed the view.
NSString *savedSearchTerm;
NSInteger savedScopeButtonIndex;
BOOL searchWasActive;
}
@property (nonatomic, copy) NSString *savedSearchTerm;
@property (nonatomic) NSInteger savedScopeButtonIndex;
@property (nonatomic) BOOL searchWasActive;
视图控制器.m
...
// when I comment out "viewDidDisappear" everything is ok, how to solve this on different way?
- (void)viewDidDisappear:(BOOL)animated
{
// save the state of the search UI so that it can be restored if the view is re-created
self.searchWasActive = [self.searchDisplayController isActive];
self.savedSearchTerm = [self.searchDisplayController.searchBar text];
self.savedScopeButtonIndex = [self.searchDisplayController.searchBar selectedScopeButtonIndex];
}...
感谢帮助