Skip to content

AFMMRecordResponseSerializer and Core Data threading #85

@jonbrooks

Description

@jonbrooks

i have encountered a Core Data threading-related crash in my app where the root of the problem is that AFMMRecordResponseSerializer's responseObjectForResponse:data:error: is not being called on the main thread, like I believed it was. (See AFHTTPRequestOperation.m, line 127 for reference.)

I am creating the AFMMRecordResponseSerializer instance on the main thread, passing in the main thread's ManagedObjectContext as the parameter. Because the response is serialized on a different thread (and not known at the time the serializer is created) using this context, Core Data actions on the main thread can cause crashes.

I am not sure how to address this problem. It seems AFMMRecordResponseSerializer's responseObjectForResponse:data:error: is designed to be adding objects to the context that's passed in, but since this work actually happens on a different thread, this would mean this is the wrong context to be doing this work.

Am I misunderstanding something here, or is this a general problem with AFMMRecordResponseSerializer? I have not yet tried to reproduce the problem in a simple project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions