Can AFNetworking return data synchronously (inside a block)?

To block the execution of the main thread until the operation completes, you could do [operation waitUntilFinished] after it’s added to the operation queue. In this case, you wouldn’t need the return in the block; setting the __block variable would be enough.

That said, I’d strongly discourage forcing asynchronous operations to synchronous methods. It’s tricky to get your head around sometimes, but if there’s any way you could structure this to be asynchronous, that would almost certainly be the way to go.

Leave a Comment