Я пытаюсь разделить весь мой код SQLite в отдельном файле .m (называемом SQLiteDB.m вместе с файлом .h). Я вызываю один из методов из другого файла: ReaderAppDelegate.m ". Код:
// create the d/b if it doesn't exist
[self checkForDatabase];
В ReaderAppDelegate.h у меня есть:
#import <UIKit/UIKit.h>
#import <sqlite3.h>
@class ReaderViewController;
@interface ReaderAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
ReaderViewController *viewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet ReaderViewController *viewController;
- (void)checkForDatabase;
//- (void)SQLiteConnection: (NSString *)defaultDBPath;
@end
Очевидно, он не может его найти, потому что он находится в SQLiteDB.m.
#import "SQLiteDB.h"
@implementation SQLiteDB
@synthesize db, dbPath, databaseKey;
//-------------- check for database or create it ----------------|
+ (void)checkForDatabase {
// Get the path to the database file
NSArray *searchPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentPath = [searchPaths objectAtIndex:0];
NSString *databasePath = [documentPath stringByAppendingPathComponent:@"ppcipher.s3db"];
// Open the database file
const char *cDatabasePath = [databasePath cStringUsingEncoding:NSUTF8StringEncoding];
if(sqlite3_open(cDatabasePath, &db) == SQLITE_OK) {
}
Как мне это исправить?