» Site Navigation |
|
|
» Advertisements |

Visit our friends over at The App Show! Steve and Dave produce a weekly show shining a light on the iPhone 2.0 software and the applications being developed by the amazing development community for the iPhone SDK!
|
» Online Users: 113 |
| 16 members and 97 guests |
| ammon, dtochetto, eddit, ipodtouchmaster05, jclardy, jeff_lamarche, johnqh, MDMstudios, NewiPhoneDeveloper, rames44, scotopia, smstromb, snatch, solomon71, storm, wynodir |
| Most users ever online was 207, 10-24-2008 at 09:29 AM. |
» Stats |
Members: 3,913
Threads: 5,612
Posts: 23,248
Top Poster: scottiphone (705)
|
| Welcome to our newest member, dtochetto |
|
 |
10-11-2008, 03:38 PM
|
#1 (permalink)
|
|
Member
Join Date: Jul 2008
Posts: 89
|
Check for Wifi?
I am nearly finished with an app that is 95% offline but does have an online component. With the iPhone this is no problem, it can connect anywhere.
But I'd like to check if an iPod Touch user can get to the internet. If not, I'd like to gray out and/or notify the user that the service is unavailable in their area.
If possible, I'd like to check if the user CAN get to the internet, not just if they are connected. Is there a way to programmatically see if they are in range of a wifi network? - again, not just check if they are currently connected to one. I've searched for wireless and wifi in the docs, but nothing useful came up, except, maybe, reachability. But I've seen other apps that do all kinds of wifi functions, including automatically connecting you to an available network.
This isn't a show stopper by any means, but if this is doable I'd love to implement it before I release the app.
Any help is appreciated!
|
|
|
10-12-2008, 12:26 PM
|
#2 (permalink)
|
|
Senior Member
Join Date: Sep 2008
Posts: 682
|
The reachability sample app shows how to do this.
|
|
|
11-06-2008, 01:10 PM
|
#3 (permalink)
|
|
Member
Join Date: Sep 2008
Posts: 70
|
phoney, youve been a great help in the past. but I have been hacking away at the reachability app for 6 hours now. I stripped the app down so it only swaps an image depending on wifi status. but if I cop the files over accordingly, how can I affect a button in a subview with its own view controller? I have a rootviewcontroller, appdelegate, viewcontroller, and a view. I think this may be an easy question but Im stumped. This should be very easy considering some of the other things ive noodled!
cheers and thanks again phoney! bozie.tehwifistatusbuttonerchangerwanter
|
|
|
11-06-2008, 02:21 PM
|
#4 (permalink)
|
|
Senior Member
Join Date: Sep 2008
Posts: 682
|
I just added NetReachability.m/h to my project. I added the following code to NetReachability. I admit that this is a little cheesy. It's a one time only check but that will work correctly in many cases. I'm intending to change my code to create an instance of NetReachability and set the delgate and update my UI when the reachability status changes. Implementing the delegate callback seems simple.
Code:
+(BOOL)networkIsReachable:(BOOL)inByWiFiOnly
{
//Make sure we have a WiFi network up & running
NetReachability* _reachability = [[NetReachability alloc] initWithDefaultRoute:NO];
BOOL result = [_reachability isReachable];
if (inByWiFiOnly)
result = result && ! [_reachability isUsingCell];
[_reachability release];
return result;
}
|
|
|
11-06-2008, 02:34 PM
|
#5 (permalink)
|
|
Member
Join Date: Sep 2008
Posts: 70
|
so how would I then check for connection in view.m? I just dont know the basic piece of code that calls that function or is it set in a global variable?
so can i do something like if(gloabalvar == 0) then dim the button?
cheers.bo
|
|
|
11-06-2008, 03:13 PM
|
#6 (permalink)
|
|
Senior Member
Join Date: Sep 2008
Posts: 682
|
After adding the code that I showed the following is what I do in my view controller's viewDidLoad:
Code:
// Check if the network is reachable and turn off the controls if not
if (! [NetReachability networkIsReachable:NO])
{
mStatusLabel.text = NSLocalizedString(@"WiFi is not available", @"no wifi status text in Pull/Push Connectivity");
mStatusLabel.textColor = [UIColor redColor];
mGetFileButton.enabled = NO;
mNetworkIsReachable = NO;
}
|
|
|
11-06-2008, 05:17 PM
|
#7 (permalink)
|
|
Member
Join Date: Sep 2008
Posts: 70
|
by NetReachability.h.m you mean the Reachability.h.m file? then if
Code:
if (! [NetReachability networkIsReachable:NO])
is in the view controller i can access t a field in the view from the viewcontroller right... ill try when i get a chance, but now im late for dinner!
thanks a ton :kicks self: learn darn you!
cheers.bo
{added} nope I cant get it to work.. now im late for dinner !
please help me obi wan kenobi, your my only hope...
Last edited by roberthuttinger; 11-06-2008 at 05:35 PM.
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|