PrepareForSegue mystery

前端 未结 3 1915
暖寄归人
暖寄归人 2021-01-28 13:47

I\'ve got a prepareForSegue method in two different VCs. One uses an if statement, while the other is intended to use a switch. The code is virtually i

3条回答
  •  心在旅途
    2021-01-28 14:30

    To solve the second error, try adding braces in your switch-case to define a context to the variables:

    -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
        NSManagedObjectContext *localContext = [NSManagedObjectContext MR_contextForCurrentThread];
        [SearchSpecs MR_truncateAllInContext:localContext];
        [localContext MR_saveToPersistentStoreAndWait];
    
        switch ([sender tag])
        {
            case aVsAButton_tag:
                {
                    UINavigationController *navController = (UINavigationController *)segue.destinationViewController;
                    AvsAViewController *aVSaVC = (AvsAViewController *)navController.topViewController;
                    aVSaVC.delegate = self;
                    SearchSpecs *thisSpec = (SearchSpecs *)[SearchSpecs MR_createInContext:localContext];
                    aVSaVC.currentSpec = thisSpec;
                }
                break;
    
            default:
                break;
        }
    
    }
    

提交回复
热议问题