stringByAppendingString, stringByAppendingPathComponent, stringByAppendingPathExtension

    1.//stringByAppendingString是在path加后缀的意思

     NSString *imagePath = [path stringByAppendingString:[NSString stringWithFormat:@"/%@",imageName]];



    2.//stringByAppendingPathComponent是在path后面加上号连接 "字符串" 让它成为完整的路径

     stringByAppendingPathComponent是添加/号,使之变成一个完整的路径

     NString * str=@“路径”;

     str=[stringByAppendingPathComponent:@"img.png"];

     打印:str就变成 路径/img.png

     

     3.//stringByAppendingPathExtension 是加后缀的意思"   自动加上 "."    "

     如果是stringByAppendingPathExtension是加后缀的意思

     NString * str=@“路径”;

     str=[str stringByAppendingPathExtension:@"jpg"];

     打印:str就变成 路径.jpg


将这段代码改为按照收缩压和舒张压的分级范围查询,要有是否需要同时满足舒张压和收缩压的选项,不再按照value值查询 - (NSMutableArray *)getBloodPresureDataField:(NSString *)field value:(NSInteger)value startTime:(NSTimeInterval)startTime endTime:(NSTimeInterval)endTime { __block NSMutableArray *array = [NSMutableArray array]; [[HWFitnessMgr sharedInstance] excuteInTransaction:^(FMDatabase *db ,BOOL * rollBack) { NSMutableString *rs = [NSMutableString string]; [rs appendString:@" where"]; //此处逻辑:若搜索字段不为COLUMN_SYNC_CLOUD_STATUS去掉本地已删除未上云的数据 if ([field isEqualToString:COLUMN_SYNC_CLOUD_STATUS]) { [rs appendFormat:@" %@ >= %.0lf and %@ <= %.0lf and %@ = %ld", Column_TimeStamp, startTime, Column_TimeStamp, endTime, field, (long)value]; } else { [rs appendFormat:@" %@ >= %.0lf and %@ <= %.0lf and %@ = %ld and %@ != %ld", Column_TimeStamp, startTime, Column_TimeStamp, endTime, field, (long)value, COLUMN_SYNC_CLOUD_STATUS, (long)HWHealthDataSyncCloudStatusDeleteNotSync]; } [rs appendFormat:@" order by %@ desc", Column_TimeStamp]; NSString *strSql = [@"select * from '%@'" stringByAppendingString:rs]; NSString *bloodPressureTable = [self getTableName:FitnessSamplePointBloodPressureTable]; FMResultSet * detailRs = [[HWFitnessMgr sharedInstance] selectBy:strSql andTable:bloodPressureTable inDatabase:db]; if (detailRs) { while ([detailRs next]) { [array addObject:[self fetchBloodPressureDataWithDetailRs:detailRs]]; } [detailRs close]; } }]; return array; }
05-16
以下是修改后的代码: - (NSMutableArray *)getBloodPresureDataField:(NSString *)field systolicValue:(NSInteger)systolicValue diastolicValue:(NSInteger)diastolicValue startTime:(NSTimeInterval)startTime endTime:(NSTimeInterval)endTime requireBoth:(BOOL)requireBoth { __block NSMutableArray *array = [NSMutableArray array]; [[HWFitnessMgr sharedInstance] excuteInTransaction:^(FMDatabase *db ,BOOL * rollBack) { NSMutableString *rs = [NSMutableString string]; [rs appendString:@" where"]; //此处逻辑:若搜索字段不为COLUMN_SYNC_CLOUD_STATUS去掉本地已删除未上云的数据 if ([field isEqualToString:COLUMN_SYNC_CLOUD_STATUS]) { if (requireBoth) { [rs appendFormat:@" %@ >= %.0lf and %@ <= %.0lf and %@ >= %ld and %@ <= %ld", Column_TimeStamp, startTime, Column_TimeStamp, endTime, COLUMN_SYSTOLIC, (long)systolicValue, COLUMN_DIASTOLIC, (long)diastolicValue]; } else { [rs appendFormat:@" %@ >= %.0lf and %@ <= %.0lf and ((%@ >= %ld and %@ <= %ld) or (%@ >= %ld and %@ <= %ld))", Column_TimeStamp, startTime, Column_TimeStamp, endTime, COLUMN_SYSTOLIC, (long)systolicValue, COLUMN_SYSTOLIC, (long)diastolicValue, COLUMN_DIASTOLIC, (long)systolicValue, COLUMN_DIASTOLIC, (long)diastolicValue]; } } else { if (requireBoth) { [rs appendFormat:@" %@ >= %.0lf and %@ <= %.0lf and %@ >= %ld and %@ <= %ld and %@ != %ld", Column_TimeStamp, startTime, Column_TimeStamp, endTime, field, (long)systolicValue, field, (long)diastolicValue, COLUMN_SYNC_CLOUD_STATUS, (long)HWHealthDataSyncCloudStatusDeleteNotSync]; } else { [rs appendFormat:@" %@ >= %.0lf and %@ <= %.0lf and ((%@ >= %ld and %@ <= %ld) or (%@ >= %ld and %@ <= %ld)) and %@ != %ld", Column_TimeStamp, startTime, Column_TimeStamp, endTime, COLUMN_SYSTOLIC, (long)systolicValue, COLUMN_SYSTOLIC, (long)diastolicValue, COLUMN_DIASTOLIC, (long)systolicValue, COLUMN_DIASTOLIC, (long)diastolicValue, COLUMN_SYNC_CLOUD_STATUS, (long)HWHealthDataSyncCloudStatusDeleteNotSync]; } } [rs appendFormat:@" order by %@ desc", Column_TimeStamp]; NSString *strSql = [@"select * from '%@'" stringByAppendingString:rs]; NSString *bloodPressureTable = [self getTableName:FitnessSamplePointBloodPressureTable]; FMResultSet * detailRs = [[HWFitnessMgr sharedInstance] selectBy:strSql andTable:bloodPressureTable inDatabase:db]; if (detailRs) { while ([detailRs next]) { [array addObject:[self fetchBloodPressureDataWithDetailRs:detailRs]]; } [detailRs close]; } }]; return array; } 修改后的代码根据收缩压和舒张压的分级范围查询数据,可选是否需要同时满足收缩压和舒张压。当 requireBoth 为 YES 时,只返回同时满足收缩压和舒张压的数据;当 requireBoth 为 NO 时,返回满足收缩压或舒张压的数据。同时,修改了变量名和注释,增强了代码的可读性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值