2
機應用崩潰的第一個記錄,當我試圖選擇數據庫中的數據和他們沒有記錄問題,同時取出由數據庫
錯誤:
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSString stringWithUTF8String:]: NULL cString'".
查詢:arrList = [app.sk lookupAllForSQL:@"select * from tblFriendDetail"];
查找AllForSQL代碼:
- (NSArray *)lookupAllForSQL:(NSString *)sql {
sqlite3_stmt *statement;
id result;
NSMutableArray *thisArray = [NSMutableArray arrayWithCapacity:4];
if ((statement = [self prepare:sql])) {
while (sqlite3_step(statement) == SQLITE_ROW) {
NSMutableDictionary *thisDict = [NSMutableDictionary dictionaryWithCapacity:4];
for (int i = 0 ; i < sqlite3_column_count(statement) ; i++) {
if (sqlite3_column_decltype(statement,i) != NULL &&
strcasecmp(sqlite3_column_decltype(statement,i),"Boolean") == 0) {
result = [NSNumber numberWithBool:(BOOL)sqlite3_column_int(statement,i)];
} else if (sqlite3_column_type(statement, i) == SQLITE_TEXT) {
result = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,i)];
} else if (sqlite3_column_type(statement,i) == SQLITE_INTEGER) {
result = [NSNumber numberWithInt:(int)sqlite3_column_int(statement,i)];
} else if (sqlite3_column_type(statement,i) == SQLITE_FLOAT) {
result = [NSNumber numberWithFloat:(float)sqlite3_column_double(statement,i)];
} else {
result = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement,i)];
}
if (result) {
[thisDict setObject:result
forKey:[NSString stringWithUTF8String:sqlite3_column_name(statement,i)]];
}
}
[thisArray addObject:[NSDictionary dictionaryWithDictionary:thisDict]];
}
}
sqlite3_finalize(statement);
return thisArray;
}
崩潰日誌
#0 0x9599d176 in __kill()
#1 0x9599d168 in kill$UNIX2003()
#2 0x95a2f89d in raise()
#3 0x95a459bc in abort()
#4 0x93311fda in __gnu_cxx::__verbose_terminate_handler()
#5 0x011a823b in _objc_terminate()
#6 0x9331017a in __cxxabiv1::__terminate()
#7 0x933101ba in std::terminate()
#8 0x933102b8 in __cxa_throw()
#9 0x011a8416 in objc_exception_throw()
#10 0x0100cef8 in +[NSException raise:format:arguments:]()
#11 0x0100ce6a in +[NSException raise:format:]()
#12 0x00a06e35 in +[NSString stringWithUTF8String:]()
#13 0x0000b6ab in -[SKDatabase lookupAllForSQL:] (self=0x59393e0, _cmd=0xf9ac, sql=0x13564) at SKDatabase.m:97
#14 0x000052f9 in -[addGroupMembers viewWillAppear:] (self=0x4f2ce40, _cmd=0xe194, animated=1 '\001') at addGroupMembers.m:34
#15 0x003649be in -[UINavigationController _startTransition:fromViewController:toViewController:]()
#16 0x0035f32a in -[UINavigationController _startDeferredTransitionIfNeeded]()
#17 0x00366562 in -[UINavigationController pushViewController:transition:forceImmediate:]()
#18 0x0035f1c4 in -[UINavigationController pushViewController:animated:]()
#19 0x00002d68 in -[GroupSelection editFriendListClicked:] (self=0x4f34da0, _cmd=0xdf58, sender=0x4f3a400) at GroupSelection.m:80
#20 0x002a64fd in -[UIApplication sendAction:to:from:forEvent:]()
#21 0x00336799 in -[UIControl sendAction:to:forEvent:]()
#22 0x00338c2b in -[UIControl(Internal) _sendActionsForEvents:withEvent:]()
#23 0x003377d8 in -[UIControl touchesEnded:withEvent:]()
#24 0x002caded in -[UIWindow _sendTouchesForEvent:]()
#25 0x002abc37 in -[UIApplication sendEvent:]()
#26 0x002b0f2e in _UIApplicationHandleEvent()
#27 0x012ff992 in PurpleEventCallback()
#28 0x01035944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__()
#29 0x00f95cf7 in __CFRunLoopDoSource1()
#30 0x00f92f83 in __CFRunLoopRun()
#31 0x00f92840 in CFRunLoopRunSpecific()
#32 0x00f92761 in CFRunLoopRunInMode()
#33 0x012fe1c4 in GSEventRunModal()
#34 0x012fe289 in GSEventRun()
#35 0x002b4c93 in UIApplicationMain()
#36 0x00002199 in main (argc=1, argv=0xbffff084) at main.m:14
請轉到GDB並激活「BT」命令並編輯您的問題完整的崩潰日誌。 – Tirth
你在方法中提到的返回類型是NSArray的,並且該方法返回的NSMutableArray! –
@iApple Thnx爲你的答案,但這沒有幫助它仍然在同一地點崩潰。 –