NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString*documentDirectory = [pathsobjectAtIndex:0];
NSString *dbPath = [documentDirectory stringByAppendingPathComponent:@"handy.db"];
NSLog(@"dbPath = %@",dbPath);
FMDatabase*dataBase = [FMDatabasedatabaseWithPath:dbPath];
[dataBaseopen];
BOOL issusscss = [dataBase executeUpdate:@"CREATE TABLE IF NOT EXISTS t_homes ( homeId text,meshName text,name text,phone text,pic text,testByte blob)"];
HDDEBUGLOG(@"model=======%d",issusscss);
[dataBaseclose];
转nsdata保存数据
for(inti =0;i< resultDict.count; i++) {
HDFamilyInfoModel*model = [HDFamilyInfoModelwhc_ModelWithJson:resultDict[i]];
inti =8;
NSData*adddata =[NSDatadataWithBytes: &ilength:sizeof(i)];
BOOL issusscss = [dataBase executeUpdate:@"INSERT INTO t_homes (homeId,meshName,name,phone,pic,testByte) VALUES (?, ?, ?, ?, ?,?);",model.homeId,model.meshName, model.name,model.phone,model.pic,adddata];
HDDEBUGLOG(@"model2222222=====%@===%d",model.homeId,issusscss);
}