Search code examples
iosoopsessioncore-dataconventions

What's the Objective-C convention for logging out/purging data?


We have a way to purge data from views, a way to purge data from Core Data, a login screen view controller to present, and a way to delete our session object.

Now undoubtedly we'll need these together to logout and show the login screen. Should there be a function in the appdelegate, or another class specifically for this functionality, or handled individually by wherever we need to logout from?

What's the Objective-C convention for this?


Solution

  • You have a user object, or a user controller to manage this functionality, right? So that should do it.

    The app delegate is for app level event handling, not user management.

    Objective-C is a language so it has no convention for user management.

    Duplicating the logout code "wherever needed" is bad design. This is really a pure OOP question and you need to define classes and allocate responsibility and ownership accordingly.