Would like to have your opinion regarding the following architecture:
In My app I have a static class (LoginManager) that handles an asynchronous login. Once the login phase is completed the app should response and transition to another state.
I have 2 implementation suggestions
using a Delegate:
import Foundation protocol LoginManagerDelegate{ func onLogin(result:AnyObject) } class LoginManager { struct Wrapper { static var delegate:LoginManagerDelegate? } class func userDidLogin(result){ Wrapper.delegate?.onLogin(result) } }
using a Notification:
import Foundation class LoginManager { class func userDidLogin(result){ NSNotificationCenter.defaultCenter().postNotificationName("onLogin", object: result) } }
Q:What would be the best approach?