From e7074cd6b278803c66c4916ade0f55f87ca4ac0c Mon Sep 17 00:00:00 2001 From: Nick Farina Date: Sat, 26 Mar 2011 13:48:54 -0700 Subject: [PATCH] Minor cleanup, bugfix. --- SampleProject/AppDelegate.h | 5 +---- SampleProject/AppDelegate.m | 15 ++++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/SampleProject/AppDelegate.h b/SampleProject/AppDelegate.h index 5207fc3..12c8b94 100644 --- a/SampleProject/AppDelegate.h +++ b/SampleProject/AppDelegate.h @@ -1,6 +1,3 @@ -@interface AppDelegate : NSObject { - UIWindow *window; - bool displayedOfflineAlert; -} +@interface AppDelegate : NSObject @end diff --git a/SampleProject/AppDelegate.m b/SampleProject/AppDelegate.m index 0943126..a0839b2 100644 --- a/SampleProject/AppDelegate.m +++ b/SampleProject/AppDelegate.m @@ -28,7 +28,7 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application { home.tableView.backgroundColor = [UIColor colorWithRed:246.0/255.0 green:246.0/255.0 blue:239.0/255.0 alpha:1]; nav.navigationBar.tintColor = [UIColor colorWithRed:235.0/255.0 green:120.0/255.0 blue:31.0/255.0 alpha:1]; - window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; + UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; [window addSubview:nav.view]; [window makeKeyAndVisible]; } @@ -40,10 +40,15 @@ - (void)googleFinished:(NSData *)responseData { // Global error handler displays a simple failure message. - (void)webRequestError:(NSNotification *)notification { - if (displayedOfflineAlert) return; - displayedOfflineAlert = YES; - UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Request Error" message:@"You appear to be offline. Please try again later." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil]; - [alertView show]; + static bool displayedOfflineAlert = NO; + static NSString *title = @"Request Error"; + static NSString *message = @"You appear to be offline. Please try again later."; + + if (!displayedOfflineAlert) { + UIAlertView *alertView = [[[UIAlertView alloc] initWithTitle:title message:message delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil] autorelease]; + [alertView show]; + displayedOfflineAlert = YES; + } } @end