我正在使用以下代码(http://stackoverflow.com/questions/4471289/how-to-filter-nsfetchedresultscontroller-coredata-with-uisearchdisplaycontroll)创建的模态视图控制器中呈现一个表格视图,因此我可以使用核心数据,NSFetchedResults和一个 UISearchbar。我终于在表格视图/搜索/详细视图结束时一切正常,但我刚刚发现了一个我似乎无法弄清楚的显示停止器。
当我使用以下方法关闭 tableview 时:
- (IBAction)doneButtonPressed:(id)sender {[self dismissModalViewControllerAnimated:YES];}
模态视图关闭,主视图加载,然后应用程序崩溃。它已经够远了,我可以从主视图控制器调用这个 nslog:
-(void) viewDidAppear:(BOOL)animated { NSLog(@"do I crash");}
我在这里遇到了错误的访问错误:
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));}}
我相信这些问题可能与弧有关。我使用的代码模板不是用于arc的,所以我做了以下更改:
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain, readonly) NSFetchedResultsController *fetchedResultsController;
到
@property (nonatomic, strong) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, strong, readonly) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSFetchedResultsController *searchFetchedResultsController;
@property (nonatomic, retain) UISearchDisplayController *mySearchDisplayController;
到
@property (nonatomic, strong) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, strong) NSFetchedResultsController *searchFetchedResultsController;
@property (nonatomic, strong) UISearchDisplayController *mySearchDisplayController;
此外,我从 didreceivememorywarning 中删除了以下内容:
[fetchedResultsController_ release];
[searchFetchedResultsController_ release];
并更改了以下内容 - (NSFetchedResultsController *)fetchedResultsController
return [[fetchedResultsController_ retain] autorelease];
到
return fetchedResultsController;
并在 - (NSFetchedResultsController *)searchFetchedResultsController
return [[searchFetchedResultsController_ retain] autorelease];
到
return searchFetchedResultsController;
我完全被难住了。任何帮助将不胜感激!