Permalink
Browse files

add alert when network is unavailable.

  • Loading branch information...
1 parent a6d7b6e commit e91723da6257d774bc4aa5e9e59cfde031c06df1 @kishikawakatsumi committed Jan 17, 2009
@@ -1,5 +1,6 @@
#import "HatenaTouchAppDelegate.h"
#import "RootViewController.h"
+#import "Reachability.h"
#import "Debug.h"
@implementation HatenaTouchAppDelegate
@@ -81,6 +82,10 @@ - (void)saveUserSettings {
- (void)applicationDidFinishLaunching:(UIApplication *)application {
LOG_CURRENT_METHOD;
[self loadUserSettings];
+
+ [[Reachability sharedReachability] setHostName:@"www.hatena.ne.jp/"];
+ [[Reachability sharedReachability] remoteHostStatus];
+
[window addSubview:[navigationController view]];
[window makeKeyAndVisible];
}
@@ -4,6 +4,7 @@
#import "WebViewController.h"
#import "HatenaTouchAppDelegate.h"
#import "NSString+XMLExtensions.h"
+#import "Reachability.h"
#import "Debug.h"
@implementation HotEntryViewController
@@ -88,6 +89,17 @@ - (void)addFeaturedEntry:(id)entry {
}
- (void)refleshIfNeeded {
+ if ([[Reachability sharedReachability] remoteHostStatus] == NotReachable) {
+ NSBundle *bundle = [NSBundle mainBundle];
+ NSDictionary *infoDictionary = [bundle localizedInfoDictionary];
+ NSString *appName = [[infoDictionary count] ? infoDictionary : [bundle infoDictionary] objectForKey:@"CFBundleDisplayName"];
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:appName message:NSLocalizedString(@"NotReachable", nil)
+ delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
+ [alert show];
+ [alert release];
+ return;
+ }
+
if (!hotEntries || !featuredEntries) {
[hotEntries removeAllObjects];
[featuredEntries removeAllObjects];
Binary file not shown.
Binary file not shown.

0 comments on commit e91723d

Please sign in to comment.