我很困..
设置:Xcode 9.4.1(9F2000) 运行于:iOS Simulator iPhone 8(11.4) sqlite3配置:sqlite3_config(SQLITE_CONFIG_SERIALIZED);
1)“ [正在记录] sqlite3.dylib的客户端中的错误:在线数据库连接的非法多线程访问”错误
if(sqlite3_prepare_v2(_contactDB, query_stmt, -1, &statment, NULL) == SQLITE_OK )
==> EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
我能做的就是改变
if(sqlite3_open([[self filepath] UTF8String], &db)!= SQLITE_OK)
到
if (sqlite3_open_v2([[self filepath] UTF8String], &db, SQLITE_OPEN_READWRITE|SQLITE_OPEN_FULLMUTEX, NULL) != SQLITE_OK)
但这导致我遇到第二个问题
2)在执行模拟器->擦除所有内容和设置后,运行该应用程序会出现错误“ libc ++ abi.dylib:以NSException类型的未捕获异常终止”
class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate
==> signal SIGABRT
完整日志
[logging] API call with invalid database connection pointer
[logging] misuse at line 123231 of [2b0954060f]
[logging] API called with NULL prepared statement
[logging] misuse at line 83511 of [2b0954060f]
SQL Error. Not able to add the record. SQL: INSERT INTO SERVER_LIST
(a, b, c, dh) VALUES ("1", "2", "3, "4")
[logging] API call with invalid database connection pointer
[logging] misuse at line 148673 of [2b0954060f]
[logging] API call with invalid database connection pointer
[logging] misuse at line 123231 of [2b0954060f]
*** Terminating appxdue to uncaught exception 'NSRangeException',
reason: '*** -[__NSArrayMobjectAtIndex:]: index 18446744073709551615
beyond bounds for empty array'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ce0d1e6 __exceptionPreprocess + 294
1 libobjc.A.dylib 0x000000010c4aa031 objc_exception_throw + 48
2 CoreFoundation 0x000000010ce4d0bc _CFThrowFormattedException + 194
3 CoreFoundation 0x000000010cd3ce76 -[__NSArrayM objectAtIndex:] + 150
4 App 0x0000000106a60570 _T06App7loginVCC13newaccountAddyyF + 1296
5 App 0x0000000106a610e4 _T06App7loginVCC13newaccountAddyyFTo + 36
6 CoreFoundation 0x000000010cda8b8c __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
7 CoreFoundation 0x000000010cda8a65 _CFXRegistrationPost + 453
8 CoreFoundation 0x000000010cda87a1 ___CFXNotificationPost_block_invoke + 225
9 CoreFoundation 0x000000010cd6a422 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1826
10 CoreFoundation 0x000000010cd695a1 _CFXNotificationPost + 609
11 Foundation 0x0000000109ccbe57 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
12 App 0x000000010663fafb __41-[AppServer verification:url:records:]_block_invoke_2 + 2363
13 App 0x00000001065dab94 __91-[AFHTTPSessionManager POST:parameters:constructingBodyWithBlock:progress:success:failure:]_block_invoke.106 + 228
14 App 0x00000001065c3db9 __72-[AFURLSessionManagerTaskDelegate URLSession:task:didCompleteWithError:]_block_invoke_2.119 + 201
15 libdispatch.dylib 0x000000010f2397ab _dispatch_call_block_and_release + 12
16 libdispatch.dylib 0x000000010f23a7ec _dispatch_client_callout + 8
17 libdispatch.dylib 0x000000010f245a3c _dispatch_main_queue_callback_4CF + 993
18 CoreFoundation 0x000000010cdcfc99 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
19 CoreFoundation 0x000000010cd93ea6 __CFRunLoopRun + 2342
20 CoreFoundation 0x000000010cd9330b CFRunLoopRunSpecific + 635
21 GraphicsServices 0x0000000110dbda73 GSEventRunModal + 62
22 UIKit 0x000000010a30f057 UIApplicationMain + 159
23 App 0x0000000106b64567 main + 55
24 libdyld.dylib 0x000000010f2b7955 start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
请帮助,错误使我陷入了困境。
谢谢!
答案 0 :(得分:2)
通过将打开的代码更改为
来解决if (sqlite3_open_v2([[self filepath] UTF8String], &db_sns, SQLITE_OPEN_READWRITE|SQLITE_OPEN_FULLMUTEX|SQLITE_OPEN_CREATE, NULL) != SQLITE_OK)