NSInternalInconsistencyException错误不在STARTUP上

时间:2013-11-14 07:54:20

标签: ios xcode sqlite tableview

我有一个表视图,其中我已经从SQlite数据库加载了元素。所有项目都正确加载。当应用程序由质量控制测试时,他们发现: 如果用户连续86次选择一行,任意行,而不执行任何搜索或任何数据库交互,则应用程序将崩溃并出现以下错误:

  'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/eliasrahme/Library/Application Support/iPhone Simulator/6.1/Applications/0C812075-EE27-4523-A92C-B4A4BD9A426F/App.app> (loaded)' with name 'pA3-c1-CuA-view-kK3-ii-tTp' and directory 'MainStoryboardIphone.storyboardc''

    *** First throw call stack:
    (0x23fc012 0x1509e7e 0x23fbdeb 0x359ef9 0x21e7e7 0x21edc8 0x21eff8 0x21f232 0x21f4da 0x2368e5 0x2369cb 0x236c76 0x236d71 0x23789b 0x2379b9 0x237a45 0x33d20b 0x18e2dd 0x151d6b0 0x29f8fc0 0x29ed33c 0x29f8eaf 0x22d2bd 0x175b56 0x17466f 0x174589 0x1737e4 0x17361e 0x1743d9 0x1772d2 0x22199c 0x16e574 0x16ecc1 0x1e98b 0x1a269 0x188df6 0x17bd66 0x17bf04 0x29f47d8 0x168e014 0x167e7d5 0x23a2af5 0x23a1f44 0x23a1e1b 0x23567e3 0x2356668 0x13dffc 0x1f1b 0x1da5)
    libc++abi.dylib: terminate called throwing an exception

奇怪的是,这个错误发生在83次连续选择行之后,既没有错误也没有奇怪的&#39; 86&#39;时代是有道理的。 请注意,该应用程序有一个搜索栏,一个addToFavorite按钮(与数据库交互)和一个addMemo(与数据库交互)。该应用程序是一个侧面板应用程序(Facebook喜欢滑动菜单)。
修改1: 这是didselectrow代码: N.B。:请注意,在点击条目1到条目86期间的任何时候,如果用户点击添加备忘录按钮,则错误将消失。所以我有想法欺骗代码,并说服用户点击了AddMemo,这就是为什么你会注意到值为75的计数器,模拟用户点击addMemo

- (void) tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{

    notYetPressed = NO;
    DetailViewController2 *Add = [[DetailViewController2 alloc]init];



    authorNAme2 = nil;

    counterF2_2 ++;
    FirstLoadApp2 = NO;
    NSLog(@"This is the value of the counter %d" , counterF2_2);
    if(counterF2_2 == 50){


        NSLog(@"The database should be closed and free");
    }
    sqlite3_stmt *sqlStatement442121;

    if(indexPath.row != indexPNumber){

        itemFirstTimeClicked = YES;

    }

    if(itemFirstTimeClicked){


        if(tempAuthorNameOnClick == authorNAme){

            itemFirstTimeClicked = NO;

        }
        [searchBar resignFirstResponder];

        firstTimeFavoritesClicked = NO;

        MenuViewController *author;

        [self->searchBar resignFirstResponder];

        if(isFiltered)
        {
            author = [filteredTableData objectAtIndex:indexPath.row];

        }
        else
        {
            author = [theauthorsLoadedFinal objectAtIndex:indexPath.row];


        }

        authorNAme =  author.genre;

        authorNAme2 = author.name;


        tempAuthorNameOnClick = [ authorNAme stringByReplacingOccurrencesOfString:@"'"
                                                                       withString:@"''"];

        NSString *formatedSql333 = [NSString stringWithFormat:@"Select keyword from Longman where description = '%@'" , tempAuthorNameOnClick ];

        const char *sql = [formatedSql333 UTF8String];

        if(sqlite3_prepare(db2, sql, -1, &sqlStatement442121, NULL) == SQLITE_ERROR)
        {
            NSLog(@"Problem with prepare statement:  %s", sqlite3_errmsg(db2));
        }else{
            while ((sqlite3_step(sqlStatement442121)==SQLITE_ROW)){


                NSString *THeAuthorNameVariableByDatabase = [[NSString alloc] initWithUTF8String:
                                                             (const char *) sqlite3_column_text(sqlStatement442121, 0)];


                THeAuthorNameVariableByDatabase = [ THeAuthorNameVariableByDatabase stringByReplacingOccurrencesOfString:@"''"withString:@"'"];

                                authorNAme2 = THeAuthorNameVariableByDatabase;
            }


            if(counterF2_2 == 75){

                UIStoryboard* storyboardMemo = [UIStoryboard storyboardWithName:@"MemoStoryboardIphone" bundle:nil];
                UIViewController* initialHelpView2 = [storyboardMemo instantiateInitialViewController];
                //   initialHelpView2.view.superview.frame = CGRectInset(initialHelpView2.view.superview.frame, 100, 50);


                [[NSNotificationCenter defaultCenter] addObserver:self
                                                         selector:@selector(didDismissSecondViewController)
                                                             name:@"SecondViewControllerDismissed"
                                                           object:nil];

                initialHelpView2.modalPresentationStyle = UIModalPresentationFormSheet;
                initialHelpView2.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;  //transition shouldn't matter
                [self presentModalViewController:initialHelpView2 animated:YES];
                initialHelpView2.view.superview.frame = CGRectInset(initialHelpView2.view.superview.frame, 100, 50);

                counterF2_2 = 0;

            }



        }


    }








    else{
        if(tempAuthorNameOnClick == authorNAme){

            UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Same Row"
                                                           message: @"Same Row Dude"
                                                          delegate: self
                                                 cancelButtonTitle:@"NO!"
                                                 otherButtonTitles:@"YES",nil];


            [alert show];
        }


        else{


            itemFirstTimeClicked = YES;

            [searchBar resignFirstResponder];

            //[self.author release];
            firstTimeFavoritesClicked = NO;


            DetailViewController2 *newInst = [[DetailViewController2 alloc]init];
            [newInst justChangeIt2];

            MenuViewController *author;

            [self->searchBar resignFirstResponder];

            if(isFiltered)
            {
                author = [filteredTableData objectAtIndex:indexPath.row];

            }
            else
            {
                author = [theauthorsLoadedFinal objectAtIndex:indexPath.row];


            }
            authorNAme =  author.genre;




            tempAuthorNameOnClick = [ authorNAme stringByReplacingOccurrencesOfString:@"'"
                                                                           withString:@"''"];

            NSString *formatedSql333 = [NSString stringWithFormat:@"Select keyword from Longman where description = '%@'" , tempAuthorNameOnClick ];
            const char *sql = [formatedSql333 UTF8String];







            if(sqlite3_prepare(db2, sql, -1, &sqlStatement442121, NULL) != SQLITE_OK)
            {
                NSLog(@"Problem with prepare statement:  %s", sqlite3_errmsg(db2));
            }else{
                while (sqlite3_step(sqlStatement442121)==SQLITE_ROW) {


                    NSString *THeAuthorNameVariableByDatabase = [[NSString alloc] initWithUTF8String:
                                                                 (const char *) sqlite3_column_text(sqlStatement442121, 0)];


                    THeAuthorNameVariableByDatabase = [ THeAuthorNameVariableByDatabase stringByReplacingOccurrencesOfString:@"''"
                                                                                                                  withString:@"'"];



                    authorNAme2 = THeAuthorNameVariableByDatabase;



                }

//                Add.detailItem = tempAuthorNameOnClick;
//                Add.detailItem2 = authorNAme2;
            }
            [newInst justChangeIt2];


        }


        fontValue = 50;
        startValue = 0;

        indexPNumber = indexPath.row;
        // [super viewDidLoad];
       // [self showPanelAViewController];

    }

    NSLog(@"This is the counter Value %d",counterF2_2);
    // sqlite3_close(db);
    //  }
    Add.detailItem2_2 = tempAuthorNameOnClick;
    Add.detailItem2 = authorNAme2;



    [self showPanelAViewController];


}

**

  • 编辑2:

** 我已经对输出进行了符号化,这就是我得到的,我知道错误行是左边的应用程序名称,右边是#行上的规范,但它没有任何意义...所以这是目录http://pastebin.com/z7NKDKZV, 和第34行中的错误,这是实际代码:

- (void) hideSideMenu
{
    // the actual animation is done by the MenuViewController
    self.window.rootViewController = self.contentViewController;
}

第35行:

- (void) slideThenHide
{
    // this animates the screenshot back to the left before telling the app delegate to swap out the MenuViewController
    // it tells the app delegate using the completion block of the animation
    [UIView animateWithDuration:0.15 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
        [screenShotImageView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    } completion:^(BOOL finished) {
      //   SidePanelAppDelegate.window.rootViewController = SidePanelAppDelegate.contentViewController;
        [appDelegateToUse hideSideMenu];
    }];
}

和第48行中的那个:

int main(int argc, char *argv[])
{

     @autoreleasepool {
    NSString *appDelegateName;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        appDelegateName =  NSStringFromClass([SidePanelAppDelegate class]);
    } else {
        appDelegateName =  NSStringFromClass([AppDelegate class]);
    }
    return UIApplicationMain(argc, argv, nil, appDelegateName);

     }
}

谢谢大家帮忙

0 个答案:

没有答案