Forum Xamarin.iOS
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

is there any known issues with iOS Akavache / SQLite Json when the object contains a DateTime?

dmstrachandmstrachan Member ✭✭

I've been stuck the last couple of days with an issue that is only occurring on iOS, using Akavache 6.10 and SQLitePCL, when I take an object placed in a SqliteEncryptedBlobCache and then try to unbox into an object I get an error. Though when the object datetime is changed to a string it works without issue.

I have read somewhere but cannot share links that iOS does something different with DateTimes and potentially stores them as a long and conversion to and from causes the unboxing to fail, is this the case?

Does anyone have any material on the matter or a potential fix?

Answers

  • LandLuLandLu Member, Xamarin Team Xamurai

    There are gaps between the different languages for DateTime. It's better to use basic type to store data in the database like string, int, or float.
    We could use a long column to store datetime type values. Compare the datetime with 1970 to get the interval. We could store this interval in your database.
    And then convert it to date on iOS using:

    NSDate date = NSDate.FromTimeIntervalSince1970(interval);
    
  • dmstrachandmstrachan Member ✭✭

    Further investigation has lead me to believe the DateTime was a redherring as testing has raised the above concerns with Akavache: https://github.com/reactiveui/Akavache/issues/606

Sign In or Register to comment.