내 스토리 보드와 homeSegue 식별자는 다음과 같습니다.
다음은 이전 viewController로 돌아가는 코드 블록입니다.
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"homeSegue"]){
ProductScannerViewController *product_scannerViewController = segue.destinationViewController;
product_scannerViewController.delegate=self;
}
if([segue.identifier isEqualToString:@"scanSegue"]){
[self.navigationController popToRootViewControllerAnimated:YES];
}
}
ScanProductViewController로 돌아가고 있습니다. 하지만 ScanProductViewController에서 검색 버튼을 다시 클릭하려고 할 때 다음 예외가 발생합니다.
2014-05-03 16:05:51.349 Spisrett[5239:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+entityForName: nil is not a legal NSManagedObjectContext parameter searching for entity name 'Product''
*** First throw call stack:
(
0 CoreFoundation 0x021d71e4 __exceptionPreprocess + 180
1 libobjc.A.dylib
이전 동작을 변경하지 않고 어떻게 ScanViewController로 돌아갈 수 있는지 제안 해주세요.
감사
충돌이 발생하는 방법은 다음과 같습니다.
-(void) configureFetchedResultsController:(NSString *) tableType;
{
//NSLog(@"This is the table tyoe");
//NSLog(tableType);
tableType=@"Product";
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:tableType inManagedObjectContext:self.context];
[fetchRequest setEntity:entity];
//Sorted by -Ishtiak
NSString *sortColumn=@"productTitle";
//actual sort..... decidedShortingColumn
NSSortDescriptor *sort = [[NSSortDescriptor alloc]
initWithKey:sortColumn ascending:YES];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
[fetchRequest setFetchBatchSize:20];
NSFetchedResultsController *theFetchedResultsController =
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:self.context
sectionNameKeyPath:nil
cacheName:nil];
fetchedResultsController = theFetchedResultsController;
fetchedResultsController.delegate = self;
}
나는 segue에 문제가 없다고 생각합니다. 문제는이 줄에서 생각하는 제품으로 엔티티 이름을 검색하는 coredata에 있습니다.
NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"product" inManagedObjectContext:appDelegateSharedObject.managedObjectContext];
그러나 coredata 파일에는 "제품"이라는 엔티티 이름이 없으므로 문제가 있습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다