PDA

View Full Version : Xcode - network failure popup




Cub
Apr 11, 2011, 02:54 AM
Hi all
I have nearly finished making my UIWebView app, and when reading over the app store requiements it says if the app will require a network it should have a popup or notification saying that there is no network or connection. I would just like a popup to say 'there is currently no network' and an ok(close) button. I have tried to implement the reachability sample into my app but I received many errors and warnings. Is it as simple as just copying and pasting or is there more to it?
Thanks for any input.
David
BTW I am a newbie when it comes to xcode so you may have to put in step by step or simple terms, if you know of a good tutorial please post it up.
Thanks



Sykte
Apr 11, 2011, 06:53 AM
Hi all
I have nearly finished making my UIWebView app, and when reading over the app store requiements it says if the app will require a network it should have a popup or notification saying that there is no network or connection. I would just like a popup to say 'there is currently no network' and an ok(close) button. I have tried to implement the reachability sample into my app but I received many errors and warnings. Is it as simple as just copying and pasting or is there more to it?
Thanks for any input.
David
BTW I am a newbie when it comes to xcode so you may have to put in step by step or simple terms, if you know of a good tutorial please post it up.
Thanks

Yes, it's that easy. Copy Reachability into your project, then implement per apples documentation. You will always get better results by posting your errors.

Cub
Apr 11, 2011, 08:00 PM
Ok I did all that, ran the simulator and no errors does this code seem right to you.
//
// Allboutnuts_comAppDelegate.m
// Allboutnuts.com
//
// Created by David z on 12/04/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Allboutnuts_comAppDelegate.h"

@implementation Allboutnuts_comAppDelegate

@synthesize window;
@synthesize webView;

#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://allboutnuts.hostzi.com/index.html"]]];

// Override point for customization after application launch.

[self.window makeKeyAndVisible];

return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}


- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}


#pragma mark -
#pragma mark Memory management

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}


- (void)dealloc {
[window release];
[super dealloc];
}


@end

Sykte
Apr 14, 2011, 06:36 AM
Quick overview it looks fine, however from the code posted I do not see reachability being used to test a proper network connection.

North Bronson
Apr 14, 2011, 09:22 AM
Is importing a whole batch of source code and running a preflight check really the best approach? What if you just try to connect the web view without the preflight check and tell the user if something goes wrong?

Cub
Apr 15, 2011, 04:45 AM
Hi everyone, thanks for the feedback, well in my xcode project I went to poject and add to project up the top and selected the reachability file. I would assume this would then check for an internet connection. The code above is after I added the reachability file. So should this all work properly?

Also is there a way to put an app link on a website for users to download without having to pay for the developer program?, because I am with the free program, and I rarely use xcode.
Thanks everyone
David

Sykte
Apr 15, 2011, 07:09 AM
Is importing a whole batch of source code and running a preflight check really the best approach? What if you just try to connect the web view without the preflight check and tell the user if something goes wrong?

Not sure what you mean "a whole bunch", reachability is a header and implementation file.... It only takes importing it into your project and either register for notifications or send a message asking about the network and it only takes a few lines of code.

Cub
Apr 15, 2011, 07:21 AM
Hi
Just asking should the code I posted work including the network check?
Also is there a way I can share my app on a website since this is for a school assignemnt it would only be downloaded or used maybe 1 to 5 times?
Thanks
David

dejo
Apr 15, 2011, 10:09 AM
Also is there a way I can share my app on a website since this is for a school assignemnt it would only be downloaded or used maybe 1 to 5 times?

You can probably just share the project folder with those involved.

Cub
Apr 15, 2011, 07:02 PM
Hi
Thanks for the response, I know this may sound silly but how do I do that is there any publish sections or do I just drag and drop the whole file into their itunes app section?
Thanks
David

dejo
Apr 17, 2011, 09:46 AM
Everyone you're sharing with has Xcode too, right?

Cub
Apr 18, 2011, 04:45 AM
Hi
Sadly no they don't :eek: , I really want it to make it look somewhat professional so they click on link or file on site and they can just download it to their itunes. Is this possible? Would anyone be willing to add it to their adhoc page, it'll only be for a while and I'll let you know when you can remove it ? Thanks
David

dejo
Apr 18, 2011, 09:20 AM
Since you started a new thread (http://forums.macrumors.com/showthread.php?t=1138071) on this topic, let's continue the conversation there.