我有一些与核心数据一起存储的值,我已经打开了应用程序的 sqlite 数据库以确保这些值被正确存储,但是当我尝试显示这些值时,它们都显得很时髦。我将来自核心数据实体的值存储在一个数组中,然后尝试调用这些值。基本上我是使用objective c开发的新手,我认为我需要一些格式化帮助。这是在输出中显示时髦数字的代码块:
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
NSString *dateString = [dateFormatter stringFromDate:dJournal.dateTime];
cell.dateLabel.text = dateString;
cell.insulinTypeLabel.text = dJournal.insulinType;
cell.glucoseLevelLabel.text = [NSString stringWithFormat:@"%e",dJournal.glucoseLevel ];
cell.carbTotalLabel.text = [NSString stringWithFormat:@"%d",dJournal.carbTotal ];
cell.insulinAmountLabel.text = [NSString stringWithFormat:@"%E",dJournal.insulinUnits ];
return cell;
这里是核心数据生成的类文件:
@property (nonatomic, retain) NSDate * dateTime;
@property (nonatomic, retain) NSNumber * glucoseLevel; //Double
@property (nonatomic, retain) NSString * insulinType; //string - no problem with
@property (nonatomic, retain) NSNumber * insulinUnits; //Double
@property (nonatomic, retain) NSNumber * carbTotal; //Integer64
我也试过:
[[NSNumber numberWithInt:carbTotal] stringValue]
没运气。提前感谢您的帮助。