嗨,新的 Iphone 程序员在这里
我正在尝试连接到我的 sqlite 数据库但遇到问题,我有 sqlite 库,并且我的支持文件夹中的数据库文件,当我加载模拟器时它没有连接
(void)viewDidLoad
{
[super viewDidLoad];
NSString *docsDir;
NSArray *dirPaths;
//Get the documents directory
dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
docsDir = [dirPaths objectAtIndex:0];
//Builds the path to the database file
databasePath = [[NSString alloc]
initWithString:[docsDir stringByAppendingPathComponent:@"PetrolWatch.sqlite"]];
NSFileManager *fileMgr = [NSFileManager defaultManager];
if([fileMgr fileExistsAtPath:databasePath]== YES)
{
lblStatus.text = @"Path Exists";
}
else
{
lblStatus.text = @"Failed to open db";
}
}
先感谢您