Skip to content

"Unknown Error Unable to save background context" when fetching array of entries with injected primary keys. #53

@vkrikun

Description

@vkrikun

Hello!

I need to fetch from server array of objects without unique identifiers. My API is:
GET /measurements
[{"bpm": 76,"timestamp" : "2014-01-02T19:20:30+01:00"}, {"bpm": 76,"timestamp" : "2014-01-02T19:20:35+02:00"}, ...]

I don't need to persist that data so I use temporary context (as you suggested in one of your previous answers). When server returns 1-5 objects - it works perfectly, but when response contain more then 5 records I get error:
Error Domain=com.mutualmobile.mmrecord Code=5 "Unknown Error Unable to save background context. Import operation unsuccessful." UserInfo=0x10d14d030 {NSLocalizedDescription=Unknown Error Unable to save background context. Import operation unsuccessful.}

I made few experiments:

  1. I tried to add primary key to may data model and inject it with entityPrimaryKeyInjectionBlock. Key injection works, but the same error when more then 5 entries.

  2. I took model scheme from 1), but instead of injecting keys I modified server to return id-s in response - everything works fine.

  3. I thought it's something wrong with the rest of my app so I created very simple test project based on MMRecordFoursquare: AFNetworking 2.0, MMDataManager copied from example, one entity in data Model. The same experience.

Looks like I'm missing something very obvious here...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions