又又好久没见了。想你们。今天写一篇关于fmdb的使用文章。在工作中,我们有时会用到数据库,所以你会需要一个好用的工具。长话短说开始进入正题。
先导入fmdb库文件。还有就是加入libsqlite3.dylib。这2个前期准备好后,我们就可以开工了。
#import "ViewController.h"
#import "FMDB.h" //导入头文件
@interface ViewController ()
@property(nonatomic,retain) FMDatabaseQueue *fmQueue;//添加一个队列属性
@end
@implementation ViewController
//你数据库的路径
-(FMDatabaseQueue *)fmQueue
{
if (_fmQueue== nil) {
NSString *dbPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/student.sqlite"];
_fmQueue = [FMDatabaseQueue databaseQueueWithPath:dbPath];
NSLog(@"%@",dbPath);
}
return _fmQue