// // BasicViewController.m // RA Image // // Created by Jack on 2017/4/27. // Copyright © 2017年 USAI. All rights reserved. // #import "BasicViewController.h" NSString *const LogoutNotification = @"LogouNotification"; @interface BasicViewController () @end @implementation BasicViewController - (NSNotificationCenter *)notificationCenter { return [NSNotificationCenter defaultCenter]; } - (void)dealloc { [self.notificationCenter removeObserver:self]; } - (void)registNofitication { [self.notificationCenter addObserver:self selector:@selector(userLogout:) name:LogoutNotification object:nil]; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (id)userDefaultsValue:(NSString *)key { return [[NSUserDefaults standardUserDefaults] valueForKey:key]; } - (void)setUserDefaultsValue:(id)value forKey:(NSString *)key { NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; [userDefaults setValue:value forKey:key]; [userDefaults synchronize]; } - (void)userLogout:(NSNotification *)notification { if (self.presentedViewController) { [self dismissViewControllerAnimated:NO completion:nil]; return; } if (self.navigationController) { [self.navigationController popToRootViewControllerAnimated:NO]; } } @end