为什么简单推送UIStoryboardSegue会失败?

时间:2014-05-17 02:42:09

标签: ios uistoryboardsegue nsexception

UIStoryboardSegue,NSException App有大约25个viewControllers的故事板。除此之外,所有segues都有效。 这是Mavericks和Xcode 5.1

应用程序以异常终止:

2014-05-15 21:16:17.004 iHungryMePlus[18768:60b] -[EditRecipeViewController viewDidLoad] 
2014-05-15 21:16:17.060 iHungryMePlus[18768:60b] -[EditRecipeViewController viewWillAppear:]     [[self tableView] isEditing]=1
2014-05-15 21:16:17.257 iHungryMePlus[18768:60b] -[EditRecipeViewController tableviewCellWithReuseIdentifier:] cell for Photo reuse = <UITableViewCell: 0x1770fd30; frame = (0 0; 320 44); layer = <CALayer: 0x1770fec0>> 
2014-05-15 21:16:42.804 iHungryMePlus[18768:60b] -[EditRecipeViewController tableView:cellForRowAtIndexPath:] created cell for Photo = <UITableViewCell: 0x1770fd30; frame = (0 0; 320 44); layer = <CALayer: 0x1770fec0>> 
2014-05-15 21:16:42.858 iHungryMePlus[18768:60b] -[EditRecipeViewController tableView:cellForRowAtIndexPath:] created cell for Photo = <UITableViewCell: 0x17713f60; frame = (0 0; 320 44); layer = <CALayer: 0x17713ef0>>
2014-05-15 21:16:42.863 iHungryMePlus[18768:60b] -[EditRecipeViewController configureCell:forIndexPath:] indexPath=<NSIndexPath: 0x175d96a0> {length = 2, path = 5 - 1}
2014-05-15 21:16:56.577 iHungryMePlus[18768:60b] TOP prepareForSegue: EDIT_RECIPE_ADDPHOTO
2014-05-15 21:16:56.616 iHungryMePlus[18768:60b] new unique id ='IHM-18768-0BBD0DF4-F19E-4C88-AFD0-415E5EA01D96'
2014-05-15 21:17:05.017 iHungryMePlus[18768:60b] -[EditRecipeViewController prepareForSegue:sender:] End EDIT_RECIPE_ADDPHOTO Prepare
2014-05-15 21:17:10.150 iHungryMePlus[18768:60b] -[AddPhotoViewController viewDidLoad] 
2014-05-15 21:17:12.794 iHungryMePlus[18768:60b] -[AddPhotoViewController viewWillAppear:] 
2014-05-15 21:40:10.604 iHungryMePlus[18768:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x2e446fd3 0x38b8fccf 0x2e380f9d 0x30cf9c6f 0x30cf9aab 0x30cf9633 0x30d10f49 0x30d10b8d 0x30d10b25 0x30c62d79 0x308e062b 0x308dbe3b 0x308dbccd 0x308db6df 0x308db4ef 0x308d521d 0x2e4122a5 0x2e40fc49 0x2e40ff8b 0x2e37af4f 0x2e37ad33 0x3329c663 0x30cc616d 0xb6015 0x3909cab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

此异常表示nil对象已添加到NSArray中。

从EditRecipeViewController到AddPhotoViewController有一个推送segue,带有segue标识符:EDIT_RECIPE_ADDPHOTO 在AddPhotoVC的每个方法的顶部都有一个NSLog。在例外之前只打印了两个。

    来自viewDidLoad的
  1. 来自viewWillAppear的
  2. 尝试在EditRecipeViewController中使用segue:

    [self performSegueWithIdentifier:@"EDIT_RECIPE_ADDPHOTO" sender:indexPath];
    

    后面的代码在-prepareSegue:sender:

    else if([segue.identifier isEqualToString:@"EDIT_RECIPE_ADDPHOTO"]){
            AddPhotoViewController *destCntrlr = (AddPhotoViewController*)segue.destinationViewController;
            Photo* aPhoto = [NSEntityDescription insertNewObjectForEntityForName:@"Photo" inManagedObjectContext:self.recipe.managedObjectContext]; //INSERT MO
            [self setPhoto:aPhoto];
            DLog(@"INSERT:self.photo=%@",self.photo);
                //NEED indexPath NOW
            NSIndexPath *indexPath= (NSIndexPath *)sender;
            [[self photo] setSortIndex:[NSNumber numberWithInt:indexPath.row]];
            NSString* stockName = [NSString stringWithFormat:@"Photo #%u", [indexPath indexAtPosition:1] + 1];
            [[self photo] setName:stockName];
            [[self photo] setModified:[NSDate date]];
            [[ self photo] setUid:[Photo calculateNewUniqueID]];
            [destCntrlr setPhoto:aPhoto];
            [destCntrlr setDelegate:self]; 
            [destCntrlr setRecipe:[self recipe]];
            DLog(@"End EDIT_RECIPE_ADDPHOTO Prepare");
    }
    

    AddPhoto视图永远不会出现。如果我选中AddRecipe初始场景[]的框是初始视图控制器,则视图会在启动时正确显示。 我还可以使用NIB文件显示AddPhoto视图。我也可以使用:

    来放置AddPhotoViewController
    UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"AddPhotoID"];
    [self presentViewController:vc animated:YES completion:nil];
    

    我如何追踪这个storyboard / segue问题的解决方案?

    • 检查我的代码[insertObject:atIndex:]
    • 中的实例
    • 设置所有异常断点,抛出
    • 在catch
    • 上设置所有异常断点
    • 为所有模块设置[NSArrary insertObject:atIndex:]的符号断点

    我希望这些断点能够停止应用并显示一个我可以通过查找的堆栈 问题。我只看到:

    https://www.dropbox.com/s/rhiz7g2792xu4nt/Screenshot%202014-05-16%2022.39.07.png

    我找不到帮助我找到此异常解决方案的日志消息。 我查看调试日志,但找不到对Exception更有用的参考。最后,我只看到上面列出的内容。 你能帮我么?

    非常感谢您的阅读,Mark

    这是下面的其他信息。

    Paulw11和Ricky,   我真的要感谢你的建议!

    该物业&#39;照片&#39;在目标视图中是:

    @property(nonatomic, strong) Photo* photo;
    

    我搜索了(包含,忽略大小写:数组)整个destinationController实现文件,即AddPhotoViewController.m。 在此搜索中找不到任何结果。

    我在SO处找到了类似问题的以下答案。

    This is a fairly common error and it has three causes:
    
    Misspelling the entity name e.g. NewsStand instead of NewsStands.
    Having a nil managed object context
    Having no or the wrong managed object model loaded.
    (1) is the most common but (3) is more common than (2). You can check that you are loading the right model with the keypath:
    
    aManagedObjectContext.persistentStoreCoordinator.managedObjectModel.entities
    then check the entity's names.
    

    AddPhotoViewController没有NSManagedObjectContext或NSManagedObjectModel的ivar。 实体名称拼写正确,&#34; Photo&#34;。

    我设置了以下断点:

    在catch上设置All Exception断点 在抛出时设置所有异常断点 为所有模块设置[NSArrary insertObject:atIndex:]的符号断点

    在-viewWillAppear结束时,堆栈是这样的:

    https://www.dropbox.com/s/ykmv1qsdnm3trbp/Screenshot%202014-05-20%2016.21.44.png
    

    然后我点击继续,堆栈看起来像这样

    https://www.dropbox.com/s/ladjxsfyafm0opu/Screenshot%202014-05-20%2016.04.43.png
    

    我再次点击继续并叠加显示:

    https://www.dropbox.com/s/tvcvh4tvd0as5wl/Screenshot%202014-05-20%2016.08.16.png
    

    现在点击继续第三次堆叠:

    https://www.dropbox.com/s/cuqd4qa9j249vxx/Screenshot%202014-05-20%2016.09.34.png
    

    SubListViewController:-prepareForSegue:sender:has

    if([segue.identifier isEqualToString:@"ADDRECIPE"]) {
          AddRecipeViewController  *destCntrlr = (AddRecipeViewController*)segue.destinationViewController;
          [destCntrlr setDelegate:self]; //create and set delegate
          CoreDataHelper *cdh = [CoreDataHelper sharedHelper];
    
          [cdh.context.undoManager beginUndoGrouping];//AddRx L:0
    
          Recipe *aRecipe =
          [NSEntityDescription insertNewObjectForEntityForName:@"Recipe"
                                        inManagedObjectContext:[self.frc managedObjectContext]];
             // Recipe object created but still needs to be named.
             // naming is done in NameRecipeViewController, which is reached
             // from the AddRecipeViewController
    
          DLog(@"aRecipe=%@",aRecipe);
          [aRecipe setUid:[Photo calculateNewUniqueID]];
          [aRecipe setModified:[NSDate date]]; //creation date
    
          destCntrlr.recipe = aRecipe;
          [destCntrlr setSubListViewController:self];
          [destCntrlr setAppDelegate:self.appDelegate];//necessary??
          [destCntrlr setDelegate:self];
    
       }
    
    //
    //  AddPhotoViewController.m
    //  iHungryMePlus
    //
    
    #import "AddPhotoViewController.h"
    #import "AddPhotoTitleViewController.h"
    #import "CoreDataHelper.h"
    ////#ifdef ICLOUD
       //#import "SVProgressHUD.h"
    ////#endif
    
    @implementation AddPhotoViewController
    @synthesize cancelButton, doneButton;
    @synthesize image,imageView;
    @synthesize recipe;
    @synthesize grabPhotoButton;
    @synthesize addTitleButton;
    @synthesize titleLabel;
    @synthesize recipePhotoDx;
    @synthesize photo;
    @synthesize delegate;
    @synthesize navigationItem , navigationBar;
    @synthesize  isEditing;
    @synthesize loadFailedLabel;
    @synthesize activityIndicatorView;
    
    @synthesize cameraLibrarySegment;
    @synthesize cameraSelected;
    //@synthesize myPopover;
    
    
    #pragma mark PopupPassData protocol
    

    //删除某个方法//

    #pragma mark VIEW Observer
    
    - (void)observeValueForKeyPath:(NSString *)keyPath
                          ofObject:(id)object
                            change:(NSDictionary *)change
                           context:(void *)context {
    
       if ([keyPath isEqualToString:@"self.imageView.image"]) {
          [self.doneButton setEnabled: self.imageView.image != nil];
          [[self loadFailedLabel] setHidden:(BOOL)([[self imageView] image] != nil)];
       }
    }
    
    #pragma mark VIEW
    
    - (void)viewDidLoad {
       DLog(@"");
       [super viewDidLoad];
    
        [[self doneButton] setEnabled:NO];
       self.cameraSelected=YES;
    
       [[self loadFailedLabel] setHidden:NO];
    
       [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleLowMemoryNotification:)
                name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
    
       [self addObserver:self
                          forKeyPath:@"self.imageView.image"
                             options:NSKeyValueObservingOptionNew
                             context:NULL];
    
    }
    
    - (void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
       DLog(@"Top");
    
        // after picking image this runs and then later the picker Delegate didFinishPickingMediaWithInfo: Moving to DidAppear:
        [[self addTitleButton] setHidden:NO];
        [[self titleLabel] setText:[photo name]];
        if([photo image]){
           [[self imageView] setImage:[UIImage imageWithData:[photo image ]]];
        }else if([[photo filename ]length]){
           [[self imageView] setImage:[UIImage imageNamed:[photo filename]]];
        }
       DLog(@"Final line in viewWillAppear.");
    }
    
    - (void)viewDidAppear:(BOOL) animated{
       [super viewDidAppear:animated];
    
       if(![self isEditing])
            [[self navigationItem] setTitle:@"Add Photo"];//insert
        else {
            [[self navigationItem] setTitle:@"Edit Photo"];
        }
          //[[self navigationItem] setTitle:([self isEditing] ? @"Edit Photo" : @"Add Photo" )];
       [[self cancelButton] setEnabled:YES];
    
       DLog(@"Final line in viewDidAppear.");
    }
    
    - (void)viewWillDisappear:(BOOL)animated {
       [super viewWillDisappear:animated];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
    
       [[self imageView] setImage:nil];
    }
    
    - (void)viewDidUnload {
          // Release any retained subviews of the main view.
          // e.g. self.myOutlet = nil;
       [self removeObserver:self forKeyPath:@"self.imageView.image"];
    
    }
    
    - (IBAction)grabPhotoAction
    {
        UIImagePickerController* imagePicker = [[UIImagePickerController alloc] init];
        //  Create a popover, add the picker as the content view controller....viola.
        imagePicker.delegate = self; //UIImagePickerControllerSourceTypeCamera
                                    //UIImagePickerControllerSourceTypePhotoLibrary
        imagePicker.sourceType = (cameraSelected) ?
          UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypePhotoLibrary;
    
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
        {
            Class classPopoverController = NSClassFromString(@"UIPopoverController"); 
            if (classPopoverController) {   // 3.2 or higher
             /*
                myPopover = [[classPopoverController alloc] initWithContentViewController:anImagePickerController];
                [myPopover presentPopoverFromRect:CGRectMake(419, 880, 127, 38)
                                                                inView:self.view permittedArrowDirections:UIPopoverArrowDirectionRight animated:YES];
                [(UIPopoverController*)popoverController setDelegate:self];
                // Store the popover in a custom property for later use.
                //[self setPopoverController:aPopoverController];
                */
            }
        }else {
             [self presentViewController:imagePicker animated:YES completion:NULL];
             //[self performSegueWithIdentifier:@"GrabPhoto" sender:self];
        }
          //#endif
    
    }
    
    - (IBAction)addTitleAction {//add or edit
    
          [self performSegueWithIdentifier:@"PHOTOTITLE" sender:self];
          //[self presentViewController:self.addPhotoTitleViewController animated:YES completion:NULL];
    }
    
    
    #pragma mark SEGUE
    
    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    
        NSLog(@"prepareForSegue: %@", segue.identifier);
       if([segue.identifier isEqualToString:@"PHOTOTITLE"]) {
          AddPhotoTitleViewController *destCntrlr = (AddPhotoTitleViewController*)segue.destinationViewController;
          [destCntrlr setIsEditing:[self isEditing]];
             //[destCntrlr setParentDoneBarButton:doneButton];
          [destCntrlr setPhoto:photo];
          [destCntrlr setTitleParentLabel:[self titleLabel]];
          [destCntrlr setRecipe :[self recipe]];
       }
       else {
          DLog(@"Can not find segue where segue.identifier=%@",segue.identifier);
       }
    }
    
    
    #pragma mark UITextFieldDelegate
    
    - (BOOL)textFieldShouldReturn:(UITextField *)textField{
        //[[self titleTextField] resignFirstResponder];
        return YES;
    }
    
       // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    #pragma mark Orientation delegate methods
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:
    (UIInterfaceOrientation)interfaceOrientation {
        return YES;
    }
    

    强文     @end

    ENDS:

    点击继续第四次和第五次,我们最后看到异常报告

    2014-05-20 16:10:22.374 iHungryMePlus [25337:60b] *由于未捕获的异常终止应用&#39; NSInvalidArgumentException&#39;,原因:&#39; * - [__NSArrayM insertObject:atIndex:]:object不能为nil&#39; * 第一次抛出调用堆栈: (0x2e446fd3 0x38b8fccf 0x2e380f9d 0x30cf9c6f 0x30cf9aab 0x30cf9633 0x30d10f49 0x30d10b8d 0x30d10b25 0x30c62d79 0x308e062b 0x308dbe3b 0x308dbccd 0x308db6df 0x308db4ef 0x308d521d 0x2e4122a5 0x2e40fc49 0x2e40ff8b 0x2e37af4f 0x2e37ad33 0x3329c663 0x30cc616d 0x13959d 0x3909cab7) libc ++ abi.dylib:以NSException类型的未捕获异常终止

    第五次继续之后的筹码是:

    https://www.dropbox.com/s/jjyuz0kjxgy7qnr/Screenshot%202014-05-20%2016.12.24.png

    整个调试日志遵循:

    代码大纲的流程是:

    1. Home (RootTableViewController) TV shows list of Recipe categories.
    2. Selection of category on RTVC -> display SubListViewController (list of Rxs for the category)
    3. Touch Edit button to reach Edit Recipe Mode, which includes display of '+' button to reach
    AddRecipeVC. 
    4. User is force to enter Name of Rx before proceeding.
    5. I then touch Add Photo button -> (AddPhotoVC) for this new Recipe object and the problems ensue.
    
    iHungryMePlus(25395,0x3b0e518c) malloc: stack logs being written into /tmp/stack-logs.25395.1b5000.iHungryMePlus.Hr5XtA.index
    iHungryMePlus(25395,0x3b0e518c) malloc: recording malloc and VM allocation stacks to disk using standard recorder
    iHungryMePlus(25395,0x3b0e518c) malloc: process 25370 no longer exists, stack logs deleted from /tmp/stack-logs.25370.108000.iHungryMePlus.ZicUAe.index
    2014-05-20 16:19:39.611 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate application:didFinishLaunchingWithOptions:] 
    Bundle bundleVer=4.5.0
    defaultsVer=4.5.0
    2014-05-20 16:19:39.623 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate applicationDocumentsDirectoryPath] Running iHungry_MeAppDelegate 'applicationDocumentsDirectoryPath'
    /var/mobile/Applications/CF17E960-FA49-425A-91ED-1F76A845E8A3/Documents
    2014-05-20 16:19:39.628 iHungryMePlus[25395:60b] bICloudSupport=0
    2014-05-20 16:19:39.632 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate application:didFinishLaunchingWithOptions:] Bottom AppDelegate.
    2014-05-20 16:19:39.718 iHungryMePlus[25395:60b] -[RootTableViewController viewDidLoad] 
    2014-05-20 16:19:39.722 iHungryMePlus[25395:60b] -[RootTableViewController configureFetch] Running RootTableViewController 'configureFetch'
    2014-05-20 16:19:39.779 iHungryMePlus[25395:60b] Running CoreDataHelper 'listenForStoreChanges'
    2014-05-20 16:19:39.786 iHungryMePlus[25395:60b] ** iCloud is DISABLED in Settings **
    2014-05-20 16:19:39.790 iHungryMePlus[25395:60b] Running CoreDataHelper 'setDefaultDataStoreAsInitialStore'
    2014-05-20 16:19:39.828 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate applicationDocumentsDirectoryPath] Running iHungry_MeAppDelegate 'applicationDocumentsDirectoryPath'
    /var/mobile/Applications/CF17E960-FA49-425A-91ED-1F76A845E8A3/Documents
    2014-05-20 16:19:39.890 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate applicationDocumentsDirectoryPath] Running iHungry_MeAppDelegate 'applicationDocumentsDirectoryPath'
    /var/mobile/Applications/CF17E960-FA49-425A-91ED-1F76A845E8A3/Documents
    2014-05-20 16:19:39.898 iHungryMePlus[25395:60b] -[CoreDataHelper isMigrationNecessaryForStore:] storeUrl=file:///var/mobile/Applications/CF17E960-FA49-425A-91ED-1F76A845E8A3/Documents/Stores/IHM_Recipes.sqlite
    2014-05-20 16:19:39.929 iHungryMePlus[25395:60b] SKIPPED MIGRATION: Source is already compatible
    2014-05-20 16:19:39.934 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate applicationDocumentsDirectoryPath] Running iHungry_MeAppDelegate 'applicationDocumentsDirectoryPath'
    /var/mobile/Applications/CF17E960-FA49-425A-91ED-1F76A845E8A3/Documents
    2014-05-20 16:19:39.987 iHungryMePlus[25395:60b] Running CoreDataHelper 'storesDidChange:'
    2014-05-20 16:19:39.991 iHungryMePlus[25395:60b] -[CoreDataHelper storesDidChange:] responding to notification storesDidCh by posting SomethingChanged note.
    2014-05-20 16:19:39.996 iHungryMePlus[25395:60b] Successfully added store: <NSSQLCore: 0x1659ad60> (URL: file:///var/mobile/Applications/CF17E960-FA49-425A-91ED-1F76A845E8A3/Documents/Stores/IHM_Recipes.sqlite)
    2014-05-20 16:19:40.004 iHungryMePlus[25395:60b] ** iCloud is DISABLED in Settings **
    2014-05-20 16:19:40.015 iHungryMePlus[25395:60b] -[RootTableViewController numberOfSectionsInTableView:] sectionCnt=0
    2014-05-20 16:19:40.019 iHungryMePlus[25395:60b] -[RootTableViewController numberOfSectionsInTableView:] sectionCnt=0
    2014-05-20 16:19:40.062 iHungryMePlus[25395:60b] -[CoreDataTVC performFetch] 
    2014-05-20 16:19:40.067 iHungryMePlus[25395:60b] -[CoreDataTVC performFetch] RTVC
    2014-05-20 16:19:40.113 iHungryMePlus[25395:60b] -[RootTableViewController numberOfSectionsInTableView:] sectionCnt=6
    2014-05-20 16:19:40.118 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 5 Cnt=2
    2014-05-20 16:19:40.123 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 0 Cnt=1
    2014-05-20 16:19:40.128 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 1 Cnt=1
    2014-05-20 16:19:40.133 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 2 Cnt=1
    2014-05-20 16:19:40.138 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 3 Cnt=3
    2014-05-20 16:19:40.143 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 4 Cnt=1
    2014-05-20 16:19:40.185 iHungryMePlus[25395:60b] __27-[CoreDataTVC performFetch]_block_invoke reloadData completed
    2014-05-20 16:19:40.189 iHungryMePlus[25395:60b] -[RootTableViewController viewWillAppear:] doDisplayHUD=0
    2014-05-20 16:19:40.194 iHungryMePlus[25395:60b] ** iCloud is DISABLED in Settings **
    2014-05-20 16:19:40.219 iHungryMePlus[25395:60b] -[RootTableViewController numberOfSectionsInTableView:] sectionCnt=6
    2014-05-20 16:19:40.224 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 5 Cnt=2
    2014-05-20 16:19:40.229 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 0 Cnt=1
    2014-05-20 16:19:40.233 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 1 Cnt=1
    2014-05-20 16:19:40.238 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 2 Cnt=1
    2014-05-20 16:19:40.243 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 3 Cnt=3
    2014-05-20 16:19:40.247 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 4 Cnt=1
    2014-05-20 16:19:40.368 iHungryMePlus[25395:60b] -[iHungry_MeAppDelegate applicationDidBecomeActive:] 
    2014-05-20 16:19:40.531 iHungryMePlus[25395:60b] -[RootTableViewController viewDidAppear:] Running RootTableViewController 'viewDidAppear:'
    2014-05-20 16:20:40.097 iHungryMePlus[25395:60b] -[RootTableViewController tableView:didSelectRowAtIndexPath:] Category.name=Desserts
    2014-05-20 16:20:40.109 iHungryMePlus[25395:60b] prepareForSegue: SLVC
    2014-05-20 16:20:40.114 iHungryMePlus[25395:60b] -[RootTableViewController prepareForSegue:sender:] Selected category=Desserts
    2014-05-20 16:20:40.150 iHungryMePlus[25395:60b] -[CoreDataTVC configureSearch] 
    2014-05-20 16:20:40.164 iHungryMePlus[25395:60b] -[SubListViewController numberOfSectionsInTableView:] 
    2014-05-20 16:20:40.372 iHungryMePlus[25395:60b] -[SubListViewController numberOfSectionsInTableView:] 
    2014-05-20 16:20:40.397 iHungryMePlus[25395:60b] -[SubListViewController configureFetch] Running SubListViewController 'configureFetch'
    2014-05-20 16:20:40.403 iHungryMePlus[25395:60b] -[CoreDataTVC performFetch] 
    2014-05-20 16:20:40.407 iHungryMePlus[25395:60b] -[CoreDataTVC performFetch] SLVC
    2014-05-20 16:20:40.461 iHungryMePlus[25395:60b] -[SubListViewController numberOfSectionsInTableView:] 
    2014-05-20 16:20:40.504 iHungryMePlus[25395:60b] __27-[CoreDataTVC performFetch]_block_invoke reloadData completed
    2014-05-20 16:20:40.511 iHungryMePlus[25395:60b] ** iCloud is DISABLED in Settings **
    2014-05-20 16:20:40.519 iHungryMePlus[25395:60b] -[SubListViewController viewWillAppear:] [[self.frc fetchedObjects] count]=12
    2014-05-20 16:20:40.524 iHungryMePlus[25395:60b] -[SubListViewController viewWillAppear:] @ self.motionManager.deviceMotionActive=0
    2014-05-20 16:20:40.531 iHungryMePlus[25395:60b] -[SubListViewController numberOfSectionsInTableView:] 
    2014-05-20 16:20:41.302 iHungryMePlus[25395:60b] -[SubListViewController viewDidAppear:] Running SubListViewController 'viewDidAppear:'
    2014-05-20 16:20:41.309 iHungryMePlus[25395:60b] ** iCloud is DISABLED in Settings **
    2014-05-20 16:20:44.528 iHungryMePlus[25395:60b] -[SubListViewController numberOfSectionsInTableView:] 
    2014-05-20 16:20:46.164 iHungryMePlus[25395:60b] prepareForSegue: ADDRECIPE
    2014-05-20 16:20:46.189 iHungryMePlus[25395:60b] -[SubListViewController prepareForSegue:sender:] aRecipe=<Recipe: 0x166f22a0> (entity: Recipe; id: 0x166f3760 <x-coredata:///Recipe/tEC40BCE6-61A1-45D2-B092-0A69DEB101D42> ; data: {
        categories =     (
        );
        comments = nil;
        ctime = 0;
        directions = nil;
        firstLetter = nil;
        ingredients = nil;
        modified = "1970-01-01 12:00:00 +0000";
        name = nil;
        nameShort = nil;
        photos =     (
        );
        ptime = 0;
        recipeID = 0;
        uid = nil;
    })
    2014-05-20 16:20:46.194 iHungryMePlus[25395:60b] new unique id ='IHM-25395-0DD78F88-E819-43B4-9012-02DB9FDE8301'
    2014-05-20 16:20:52.791 iHungryMePlus[25395:60b] -[AddRecipeViewController prepareForSegue:sender:] segue.identifier:NAMERECIPE
    2014-05-20 16:20:52.795 iHungryMePlus[25395:60b] -[AddRecipeViewController prepareForSegue:sender:] nameRecipeViewController=<NameRecipeViewController: 0x1663a350>
    2014-05-20 16:20:55.583 iHungryMePlus[25395:60b] -[NameRecipeViewController textField:shouldChangeCharactersInRange:replacementString:]  editLengthB4 = 0
     range.length =0
     replaceStrLen=1
    2014-05-20 16:20:55.587 iHungryMePlus[25395:60b] -[NameRecipeViewController textField:shouldChangeCharactersInRange:replacementString:] Length=1
    2014-05-20 16:20:56.015 iHungryMePlus[25395:60b] -[NameRecipeViewController textField:shouldChangeCharactersInRange:replacementString:]  editLengthB4 = 1
     range.length =0
     replaceStrLen=1
    2014-05-20 16:20:56.019 iHungryMePlus[25395:60b] -[NameRecipeViewController textField:shouldChangeCharactersInRange:replacementString:] Length=2
    2014-05-20 16:20:56.365 iHungryMePlus[25395:60b] -[NameRecipeViewController textField:shouldChangeCharactersInRange:replacementString:]  editLengthB4 = 2
     range.length =0
     replaceStrLen=1
    2014-05-20 16:20:56.369 iHungryMePlus[25395:60b] -[NameRecipeViewController textField:shouldChangeCharactersInRange:replacementString:] Length=3
    2014-05-20 16:20:57.837 iHungryMePlus[25395:60b] -[AddRecipeViewController tableviewCellWithReuseIdentifier:] Add Photo cell for Photo reuse = <UITableViewCell: 0x167c0590; frame = (0 0; 320 44); layer = <CALayer: 0x167c0720>> 
    2014-05-20 16:20:57.844 iHungryMePlus[25395:60b] -[AddRecipeViewController configureCell:forIndexPath:] indexPath=<NSIndexPath: 0x167c0580> {length = 2, path = 5 - 0}
    2014-05-20 16:20:57.850 iHungryMePlus[25395:60b] -[AddRecipeViewController configureCell:forIndexPath:] cell=<UITableViewCell: 0x167c0590; frame = (0 0; 320 44); text = 'add photo'; layer = <CALayer: 0x167c0720>>
    2014-05-20 16:20:57.985 iHungryMePlus[25395:60b] -[CoreDataTVC controllerWillChangeContent:] 
    2014-05-20 16:20:57.989 iHungryMePlus[25395:60b] -[CoreDataTVC controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:] 
    2014-05-20 16:20:57.993 iHungryMePlus[25395:60b] -[CoreDataTVC controllerDidChangeContent:] 
    2014-05-20 16:20:57.997 iHungryMePlus[25395:60b] -[RootTableViewController numberOfSectionsInTableView:] sectionCnt=6
    2014-05-20 16:20:58.001 iHungryMePlus[25395:60b] -[RootTableViewController numberOfSectionsInTableView:] sectionCnt=6
    2014-05-20 16:20:58.005 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 0 Cnt=1
    2014-05-20 16:20:58.009 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 1 Cnt=1
    2014-05-20 16:20:58.013 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 2 Cnt=1
    2014-05-20 16:20:58.016 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 3 Cnt=3
    2014-05-20 16:20:58.021 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 4 Cnt=1
    2014-05-20 16:20:58.029 iHungryMePlus[25395:60b] -[RootTableViewController tableView:numberOfRowsInSection:] rowsInSection 5 Cnt=2
    2014-05-20 16:21:16.090 iHungryMePlus[25395:60b] -[AddRecipeViewController prepareForSegue:sender:] segue.identifier:ADDPHOTO
    2014-05-20 16:21:16.093 iHungryMePlus[25395:60b] -[AddRecipeViewController prepareForSegue:sender:] beginUndoGrouping]; //AddRx.AddPhoto L:1
    2014-05-20 16:21:16.103 iHungryMePlus[25395:60b] new unique id ='IHM-25395-5B4352A6-D3BB-4922-A1CF-008B388CA3C3'
    2014-05-20 16:21:16.144 iHungryMePlus[25395:60b] -[AddPhotoViewController viewDidLoad] 
    2014-05-20 16:21:20.907 iHungryMePlus[25395:60b] -[AddPhotoViewController viewWillAppear:] Top
    2014-05-20 16:22:32.161 iHungryMePlus[25395:60b] -[AddPhotoViewController viewWillAppear:] Final line in viewWillAppear.
    2014-05-20 16:22:40.087 iHungryMePlus[25395:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
    *** First throw call stack:
    (0x2e446fd3 0x38b8fccf 0x2e380f9d 0x30cf9c6f 0x30cf9aab 0x30cf9633 0x30d10f49 0x30d10b8d 0x30d10b25 0x30c62d79 0x308e062b 0x308dbe3b 0x308dbccd 0x308db6df 0x308db4ef 0x30c66401 0x2e41225b 0x2e41172b 0x2e40ff1f 0x2e37af4f 0x2e37ad33 0x3329c663 0x30cc616d 0x13a775 0x3909cab7)
    libc++abi.dylib: terminating with uncaught exception of type NSException
    (lldb) 
    

1 个答案:

答案 0 :(得分:0)

我愚蠢地将一个NavigationItem添加到我的ViewController!

我通过在Apple Developer Tech Support中将其变成TSI来了解这一点。

技术写道:

从AddPhotoViewController.h中删除此行

@property(nonatomic, retain) UINavigationItem* navigationItem;

以及AddPhotoViewController.m

中的这一行
@synthesize navigationItem;

以便您的视图控制器再次继承标准行为。