diff options
-rw-r--r-- | Juick/AppDelegate.h | 2 | ||||
-rw-r--r-- | Juick/AppDelegate.m | 4 | ||||
-rw-r--r-- | Juick/ViewControllers/DialogsViewController.m | 9 | ||||
-rw-r--r-- | Juick/ViewControllers/DiscoverViewController.m | 10 | ||||
-rw-r--r-- | Juick/ViewControllers/LoginViewController.m | 3 |
5 files changed, 15 insertions, 13 deletions
diff --git a/Juick/AppDelegate.h b/Juick/AppDelegate.h index a493664..931cf0b 100644 --- a/Juick/AppDelegate.h +++ b/Juick/AppDelegate.h @@ -14,6 +14,8 @@ -(void) registerForRemoteNotifications; ++(AppDelegate *) shared; + @property (strong, nonatomic) NSNumber *pushedThread; @property (strong, nonatomic) NSString *pushedUname; diff --git a/Juick/AppDelegate.m b/Juick/AppDelegate.m index aa3a48b..5aff686 100644 --- a/Juick/AppDelegate.m +++ b/Juick/AppDelegate.m @@ -125,4 +125,8 @@ self.pushedUname = userInfo[@"uname"]; } ++(AppDelegate *) shared { + return (AppDelegate *)[UIApplication sharedApplication].delegate; +} + @end diff --git a/Juick/ViewControllers/DialogsViewController.m b/Juick/ViewControllers/DialogsViewController.m index 05f0958..c4ace7f 100644 --- a/Juick/ViewControllers/DialogsViewController.m +++ b/Juick/ViewControllers/DialogsViewController.m @@ -66,11 +66,10 @@ -(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"chatSegue"]) { NSString *uname; - AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; - if ([appDelegate.pushedUname length] > 0) { - uname = [appDelegate.pushedUname copy]; - appDelegate.pushedThread = nil; - appDelegate.pushedUname = nil; + if ([[AppDelegate shared].pushedUname length] > 0) { + uname = [[AppDelegate shared].pushedUname copy]; + [AppDelegate shared].pushedThread = nil; + [AppDelegate shared].pushedUname = nil; } else { Chat *chat = [self.chats objectAtIndex:[self.tableView indexPathForSelectedRow].row]; uname = chat.uname; diff --git a/Juick/ViewControllers/DiscoverViewController.m b/Juick/ViewControllers/DiscoverViewController.m index 092c19c..27b273b 100644 --- a/Juick/ViewControllers/DiscoverViewController.m +++ b/Juick/ViewControllers/DiscoverViewController.m @@ -16,7 +16,6 @@ @interface DiscoverViewController () -@property(nonatomic, strong) AppDelegate *appDelegate; @property NSString *selectedUser; @end @@ -49,7 +48,6 @@ [self refreshData]; } [super viewDidLoad]; - self.appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate; } -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { @@ -76,10 +74,10 @@ if ([segue.identifier isEqual: @"threadViewSegue"]) { NSNumber *mid; BOOL scrollToEnd = NO; - if (self.appDelegate.pushedThread != nil) { - mid = [self.appDelegate.pushedThread copy]; - self.appDelegate.pushedThread = nil; - self.appDelegate.pushedUname = nil; + if ([AppDelegate shared].pushedThread != nil) { + mid = [[AppDelegate shared].pushedThread copy]; + [AppDelegate shared].pushedThread = nil; + [AppDelegate shared].pushedUname = nil; scrollToEnd = YES; } else { Message *msg = [self.messages objectAtIndex:[self.tableView indexPathForSelectedRow].row]; diff --git a/Juick/ViewControllers/LoginViewController.m b/Juick/ViewControllers/LoginViewController.m index c0b1a0d..e1b12f2 100644 --- a/Juick/ViewControllers/LoginViewController.m +++ b/Juick/ViewControllers/LoginViewController.m @@ -62,8 +62,7 @@ NSString *password = [SAMKeychain passwordForService:[[NSBundle mainBundle] bundleIdentifier] account:@"com.juick.password"]; [[APIClient sharedClient].manager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:password]; - AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate]; - [app registerForRemoteNotifications]; + [[AppDelegate shared] registerForRemoteNotifications]; CATransition* transition = [CATransition animation]; transition.duration = 0.3; transition.type = kCATransitionFade; |