- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到了一个奇怪的问题。我刚刚向我的 iPhone 项目添加了一个测试数据库,名为“pharmacies.sqlite3”。我已将该文件复制到我的 iPhone 项目中的 SUPPORTING FILES 文件夹中。
但是,尽管我将自定义数据库文件复制到 iPhone 上的文档文件夹中,我还是收到一条消息,我正在查找的表不存在。尽管它是可用的。我稍微重构了我的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// FMDB
self.databaseName = [[NSString alloc] initWithString:@"pharmacies.sqlite3"];
NSString *documentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
self.databasePath = [documentsDir stringByAppendingPathComponent:self.databaseName];
[self createAndCheckDatabase];
[self getPharmacies];
}
这是我的辅助方法:
- (void)createAndCheckDatabase
{
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
success = [fileManager fileExistsAtPath:self.databasePath];
if (success) {
return;
}
NSString *databasePathFromApp = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:self.databaseName];
[fileManager copyItemAtPath:databasePathFromApp toPath:self.databasePath error:nil];
}
- (void)getPharmacies
{
FMDatabase *db = [FMDatabase databaseWithPath:self.databasePath];
[db setLogsErrors:YES];
[db setTraceExecution:YES];
[db open];
FMResultSet *results = [db executeQuery:@"SELECT * FROM pharmacies"];
while ([results next]) {
NSString *name = [results stringForColumn:@"name"];
NSLog(@"Apotheke: %@", name);
}
[db close];
}
但是仍然没有找到 table ..我错过了什么吗?没有错误消息表明复制不起作用......
最佳答案
我遇到了同样的问题,结果发现问题是 sqlite 数据库没有出现在“复制捆绑资源”列表中(在“选择项目”下,然后单击“构建阶段”),因此它没有与其余的一起打包资源。我正在使用 XCode 6。
我认为发生的情况是 fmdb open 函数创建了一个空数据库。当您查询时,它会提示您的表丢失,因为您自己的数据库从未被复制。
关于iphone - FMDB 错误 1 : no such table,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10972143/
我正在使用 Xcode 7.2 和 swift 2。部署目标是 ios 9.0 这个问题与之前提出的许多问题类似,但我的问题并不常见,或者没有找到任何引用。 我为 iOS 创建了一个 cocoa to
代码 A FMDBDatabase *db = xxxxx [db beginTransaction]; [db executeUpdate:xxxx]; xxxxxxx 代码 B FMDBDatab
我正在尝试打开我在资源中的项目中拥有的数据库。 问题是好像找不到数据库文件! 我尝试了完整的路径,它可以工作,但这不是一个好的解决方案。 我想现在怎么打开它! 我正在使用此代码: db = [FMDa
我是 iOS 开发新手,我遇到了一个问题。我正在尝试使用 FMDB 更新表,但尽管它在所有模拟器中都有效,但在真实设备上却不起作用。我确信数据库已传输到设备,因为所有选择查询都正常运行。另一方面,所有
我想检查数据库中是否有一个 id 列表。这是我的代码... NSArray *array = [NSArray arrayWithObjects:@"1",@"2",@"3",nil]; NSStri
我使用 sqlite 和 fmdb 包装器。我的加载数据库代码是这样的: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocument
使用主线程在数据库中插入行/选择行是一个好习惯,还是我应该分派(dispatch)一个异步队列来执行此操作?在这种情况下..实现这一目标的正确做法是什么? 谢谢! 最佳答案 因为这被标记为 fmdb
我想开始使用 FMDatabaseQueue 在我的应用程序中的不同线程中同时运行查询,但我不确定如何在一个方法中实现读取操作。我正在使用此处的示例:http://ccgus.github.io/fm
您好,我正在使用 sqlite 和 FMDB 开发一个项目。一切正常。但是如果我删除旧数据库并添加一个新数据库,iphone 将无法识别有一个新数据库。它仍然适用于旧数据库。 如果我从模拟器中删除应用
我正在从数据库中获取大量数据。这是我正在做的事情的一个例子。 NSMutableArray *array = [[NSMutableArray alloc] init]; FMResultSet *s
这可能吗?如果可能的话,人们会怎么做?考虑到 Google 和 Stack 搜索,关于该主题的信息有点稀疏,批量插入有很多,但批量更新没有可靠信息。 最佳答案 是的,如果您插入正确的 SQL 是可能的
我在使用 fmdb 执行更新查询时遇到问题。它会在没有任何错误的情况下锁定应用程序。 它停在这一行: [db executeUpdate:@"UPDATE categories SET number_
您好,我正在尝试对数据库中的现有行执行更新。我一直在我的 sql 语句中使用问号 ? 并为 FMDB 提供一个值数组来替换 ?。以下是使用此逻辑的示例 INSERT 语句: let sqlStatem
SQL FMDB 的修饰符在哪里描述?特别是,如何在要插入的字符串中放置引号。比如我想将名称“Mac's Place”插入数据库?谢谢 最佳答案 如果在 SQL 中使用 executeUpdate 和
在 FMDB 中,next 函数(如 if a!.next {})既检查是否有另一行,也检查是否有另一行,我们可以单独做这些事情吗,比如只检查是否有另一行? 我已经阅读了文档,但似乎没有这种直接的方法
我想对 FMDB 是否成功创建表进行单元测试。 db.createGoodTable("good") XCTAssertTrue(db.tableExists("good")!) 我不能通过考试。错误
在我的 ios 应用程序中,我使用 FMDB 连接到 sqlite3 数据库。在app中,多线程会用到db,所以我创建了一个单例: + (id)instance { static DBManager
我正在使用 FMDB,当我想返回一些值时我正在使用 FMDatabase,当我不需要时我正在使用 FMDatabaseQueue返回任何值。当我添加到数据库并使用 FMDatabaseQueue 我没
我在我的应用程序中使用多线程环境,我需要不断访问 sqlite 数据库以更新我的 View ,并通过多个后台线程使用服务器数据更新我的数据库。现在我正在使用 FMDB 进行数据库交互,但仍然遇到数据库
在我的项目中,我使用 cocoapods 添加了 FMDB。然后我为 FMDB 创建了一个桥接头。但是,当我使用 #import "FMDB.h" 导入 FMDB.h 时,我收到错误消息“找不到 FM
我是一名优秀的程序员,十分优秀!