Jules Jules - 3 years ago 177
iOS Question

CloudKit, can't save NSDate to Date/Time field, "Invalid Date"

I can't seem to save an NSDate to cloudkit, in the dashboard, it shows an

Invalid Date

I've tried sending up various combinations of an
[NSDate date]

Other values save fine.

I've also tried manually adding a date to the dashboard and this shows fine.

I thought it might be a bug in cloudkit, any suggestions, where I go from here?

Although I could file a radar, I'm in a bit of a rush with my app.

Here's my code...

CKRecordID *recordId = [[CKRecordID alloc] initWithRecordName: record_name_guid
zoneID: [self customZone]];

CKRecord *record = [[CKRecord alloc] initWithRecordType: @"students" recordID:recordId];

record[@"enroll_date"] = [SharedCommon convertDBStringDateToNSDate: enroll_date];
record[@"best_tbl"] = [NSNumber numberWithInteger: best_tbl];

[recordsToUpload addObject:record];

CKModifyRecordsOperation *op = [[CKModifyRecordsOperation alloc]
initWithRecordsToSave: records
recordIDsToDelete: deleteIds];

op.savePolicy = CKRecordSaveAllKeys;

op.modifyRecordsCompletionBlock = ^(NSArray *savedRecords,
NSArray *deletedRecordIDs, NSError *operationError)

Answer Source

I've seen this too. With the old dashboard my dates were fine. I'm thinking it's a bug.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download