diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index c9dab2ed..5299057a 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -254,20 +254,18 @@ class ProfileViewController: UIViewController { var customNavigationItem: UINavigationItem = UINavigationItem(title: "Details") - func setBackButtonWithTitle() { - let backBarButtonItem = UIBarButtonItem(image: UIImage(named: "icon_back"), style: UIBarButtonItemStyle.Plain, target: self, action: "popBack") - backBarButtonItem.tintColor = UIColor.whiteColor() - - customNavigationItem.leftBarButtonItem = backBarButtonItem - } - - func popBack() { - self.navigationController?.popViewControllerAnimated(true) + + // MARK: Life cycle + + deinit { + NSNotificationCenter.defaultCenter().removeObserver(self) } override func viewDidLoad() { super.viewDidLoad() + NSNotificationCenter.defaultCenter().addObserver(self, selector: "cleanForLogout", name: EditProfileViewController.Notification.Logout, object: nil) + if profileUser == nil { if let myUserID = YepUserDefaults.userID.value, @@ -488,6 +486,21 @@ class ProfileViewController: UIViewController { // MARK: Actions + func setBackButtonWithTitle() { + let backBarButtonItem = UIBarButtonItem(image: UIImage(named: "icon_back"), style: UIBarButtonItemStyle.Plain, target: self, action: "popBack") + backBarButtonItem.tintColor = UIColor.whiteColor() + + customNavigationItem.leftBarButtonItem = backBarButtonItem + } + + func popBack() { + navigationController?.popViewControllerAnimated(true) + } + + func cleanForLogout() { + profileUser = nil + } + func updateProfileCollectionView() { profileCollectionView.collectionViewLayout.invalidateLayout() profileCollectionView.reloadData()