1
코드를 컴파일 할 때 다음 오류가 발생합니다. 나는 sqlite 3 데이터베이스에 연결하려고하고 UIAlertView에 입력 한 텍스트를 테이블에 저장하여 새 list.Any를 작성하고 모든 도움을 주시면 감사하겠습니다.이 오류가 발생하는 이유를 알아 내려고 노력했습니다. sql 파일은 프로젝트에 있으며 sqlitebrowser를 사용하여 생성되었습니다.NSException의 예외 유형을 종료합니다.
2014-12-04 19:10:29.917 SmartShop[7964:60b] -[DBManager initWithDatabaseFile:]: unrecognized selector sent to instance 0x109239910
2014-12-04 19:10:29.925 SmartShop[7964:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DBManager initWithDatabaseFile:]: unrecognized selector sent to instance 0x109239910'
*** First throw call stack:
(
0 CoreFoundation 0x0000000101a35495 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010179499e objc_exception_throw + 43
2 CoreFoundation 0x0000000101ac665d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000101a26d8d ___forwarding___ + 973
4 CoreFoundation 0x0000000101a26938 _CF_forwarding_prep_0 + 120
5 SmartShop 0x0000000100001c62 -[ViewController viewDidLoad] + 114
6 UIKit 0x000000010043759e -[UIViewController loadViewIfRequired] + 562
7 UIKit 0x0000000100437777 -[UIViewController view] + 29
8 UIKit 0x00000001007422e2 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 390
9 UIKit 0x000000010037dffa -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1109
10 UIKit 0x000000010037db9f -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 36
11 UIKit 0x000000010037daef -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 101
12 UIKit 0x000000010037cdfe -[UIWindow _updateToInterfaceOrientation:duration:force:] + 377
13 UIKit 0x000000010043b70a -[UIViewController _tryBecomeRootViewControllerInWindow:] + 147
14 UIKit 0x0000000100377b1b -[UIWindow addRootViewControllerViewIfPossible] + 490
15 UIKit 0x0000000100377c70 -[UIWindow _setHidden:forced:] + 282
16 UIKit 0x0000000100380ffa -[UIWindow makeKeyAndVisible] + 51
17 UIKit 0x000000010033cc98 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1788
18 UIKit 0x0000000100340a0c -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 660
19 UIKit 0x0000000100351d4c -[UIApplication handleEvent:withNewEvent:] + 3189
20 UIKit 0x0000000100352216 -[UIApplication sendEvent:] + 79
21 UIKit 0x0000000100342086 _UIApplicationHandleEvent + 578
22 GraphicsServices 0x0000000103bae71a _PurpleEventCallback + 762
23 GraphicsServices 0x0000000103bae1e1 PurpleEventCallback + 35
24 CoreFoundation 0x00000001019b7679 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
25 CoreFoundation 0x00000001019b744e __CFRunLoopDoSource1 + 478
26 CoreFoundation 0x00000001019e0903 __CFRunLoopRun + 1939
27 CoreFoundation 0x00000001019dfd83 CFRunLoopRunSpecific + 467
28 UIKit 0x00000001003402e1 -[UIApplication _run] + 609
29 UIKit 0x0000000100341e33 UIApplicationMain + 1010
30 SmartShop 0x0000000100002563 main + 115
31 libdyld.dylib 0x0000000101fba5fd start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
다음은 SQLite3 db 및 다른 코드를 참조하는 ViewController의 코드입니다. 당신은 initWithDatabaseFile:
요구하고 있지만, 메소드의 이름이 initWithDatabaseFilename:
입니다
-(instancetype)initWithDatabaseFilename:(NSString *)dbFilename{
self = [super init];
if (self) {
// Set the documents directory path to the documentsDirectory property.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
self.documentsDirectory = [paths objectAtIndex:0];
// Keep the database filename.
self.databaseFilename = dbFilename;
// Copy the database file into the documents directory if necessary.
[self copyDatabaseIntoDocumentsDirectory];
}
return self;
}
그게 헤더 파일이 잘못된 메서드 이름을 참조하고있었습니다. 그렇게 간단한 것을 지적 해 주셔서 감사합니다. 나는 너무 오랫동안 그것을보고 있었고 쉬운 대답을 놓친 것 같아요. 정말 고마워요. – chrisotto6