I have some values that are stored with core data, and I have opened the application’s sqlite database to make sure that the values are being stored correctly, but when I try to display the values they come out all funky. I store the values from the core data entity in an array then try to call the values. Basically I am new to developing with objective c and think I need some formatting help. Here is the code block displaying the funky numbers on output:
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;
Here is the core data generated class file:
@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
I also have tried:
[[NSNumber numberWithInt:carbTotal] stringValue]
no luck. Thanks in advance for any help.
Why are you using
%e,%detc? If you want to print out objective-C objects you need to use the%@format specifier, e.g.If you are displaying numbers however, you should actually be using an instance of
NSNumberFormatterto generate locale-aware strings.