small medium large xlarge

02 Apr 2018, 17:32
Alexis Drnt (1 post)

hey Marcus,

I’m actually struggling with the Sign in of my app. I created a loginOperation to perform the sign in request. But I don’t really know how to inform my viewController that the request is done, if it worked or not (e.g. invalid credentials).

Should I post a NSNotification from my operation and catch it in my viewController ?

Should I store the response status, catch it in the completion block of the NSOperation, and send it to my ViewController through a callback ?

02 Apr 2018, 17:57
Marcus S. Zarra (285 posts)


This question is not related to Core Data.

Having said that, all network operations should be fired through an NSOperation and then the response to that network operation; in this case login; can be sent back via a number of routes:

  • Delegation, the view controller can be the delegate of the operation. This is tighter coupling than I prefer
  • NSNotification, very decoupled and perfectly viable
  • Block callback, the view controller can pass a block to the operation and the operation runs that block on a pass/fail.

Of the three, I used to prefer notifications but I have been leaning towards blocks more recently as they strike a nice balance.

You must be logged in to comment