I'm following the Core Data Utility tutorial and I've implemented the custom managed object class. It builds and runs fine but the values don't seem to be correct. My CDCLI.cdcli file is full of objects like this one:
<object type="RUN" id="z114">
<attribute name="processid" type="int64">1334</attribute>
<attribute name="date" type="date">369155986.60885798931121826172</attribute>
</object>
That "date" attribute doesn't look like a date. The date and the processID attribute are being set like so:
// Attribute: Date
NSAttributeDescription *dateAttribute = [[NSAttributeDescription alloc] init];
[dateAttribute setName:@"date"];
[dateAttribute setAttributeType:NSDateAttributeType];
[dateAttribute setOptional:NO];
// Attribute: Process ID
NSAttributeDescription *idAttribute = [[NSAttributeDescription alloc] init];
[idAttribute setName:@"processID"];
[idAttribute setAttributeType:NSInteger64AttributeType];
[idAttribute setOptional:NO];
[idAttribute setDefaultValue:[NSNumber numberWithInteger:-1]];
Based on the following method, I was expecting to receive "0" as the processID attribute value, which I'm not.
- (void)setNilValueForKey:(NSString *)key {
if ([key isEqualToString:@"processID"]) {
self.processID = 0;
} else {
[super setNilValueForKey:key];
}
}
In fact, adding a few NSLog statements to that method tells me it isn't even being called, which I'll have to figure out.
Does anyone know what the date and processID attributes are supposed to look like so I can be sure I'm getting the correct values?
The date value looks good to me. The internal format is the number of seconds since the reference date (Jan 1, 2001, GMT). That value would be approximately 11.7 years, which seems like a reasonable date.
Likewise, the process ID of 1334 seems to be an appropriate value for a PID.
Finally, in your code, you do this:
but your usage if the attribute name seems inconsistent. The log shows
processid
, your first set of code usesprocessID
, and the second set of code usesProcessID
.