mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-11 13:56:10 +10:00
fix logout and relogin may crash for realm in profile
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user