0
votes

This is my first time trying to integrate Simperium in one of my iOS core data projects. Though the initial sync works great. I'm seeing a ton of crashes at later stages with the following log.

2013-03-26 18:40:08.460 APP[2468:ae03] *** Assertion failure in -[SPMemberDate diff:otherValue:], /path/to/simperium-ios-develop/Simperium/SPMemberDate.m:48

2013-03-26 18:40:08.465 APP[2468:ae03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Simperium error: couldn't diff dates because their classes weren't NSDate'

Printing the results of [thisValue class] & [otherValue class] in the method that occupies line 48 of SPMemberDate.m shows that at one point, thisValue is an __NSDate object, while otherValue is __NSCFNumber object.

The values of the culprit objects are always the following :-

1970-01-01 00:00:00 +0000 for thisValue

and

0 for otherValue

I'm at loss for where to look next to try & debug this issue. What could be returning an NSNumber instead of an NSDate? And, what could be returning a date from the 70s? I'm fairly ceratin, it's nothing in my code. Any help would be nice.

2
That may be time interval sice 1970... you need to convert that into a date. - Anoop Vaidya
@AnoopVaidya That is already returned as an NSDate. Where & how exactly should I be converting it? - Sam J.

2 Answers

0
votes

Are you only syncing between iOS devices, or are you also syncing to a web app or backend service? Date values are currently transmitted as numbers on the wire (number of seconds since 1970), so if you're sending dates to Simperium from a non-iOS device, you'll need to use that format.

The Simperium iOS library should be handling conversion to/from NSDate on iOS though. It's open source, so you can try downloading it and digging in a bit further to see what might be going wrong: https://github.com/Simperium/simperium-ios

0
votes

You are getting the number as timeinterval since 1970,

You can convert it into date by:

// The time interval 
NSTimeInterval theTimeInterval = ...;
// Get the system calendar
NSCalendar *sysCalendar = [NSCalendar currentCalendar];

// Create the NSDates
NSDate *date1 = [[NSDate alloc] init];
NSDate *date2 = [[NSDate alloc] initWithTimeInterval:theTimeInterval sinceDate:date1];