我有一个表格视图,其中我从 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 行选择之后,无论是错误还是奇怪的 '86' 次都没有任何意义。请注意,该应用程序有一个搜索栏、一个 addToFavorite 按钮(与数据库交互)和一个 addMemo(与数据库交互)。该应用程序是一个侧面板应用程序(facebook Like 滑动菜单)。
编辑 1:
这是 didselectrow 代码:
注意:请注意,在单击条目 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);
}
}
谢谢大家帮忙