reachability Detecting Network status

Source: Internet
Author: User

-(void) Viewwillappear: (BOOL) animated

{

[Iosexcept judgenetwork];//Networking

NSLog (@ "Check the network later ......");

Self.backImage.hidden = yes;//Hide background image

if (Ios.isdaymode = = 1)

{

[Self.backimage setimage:[uiimage imagenamed:@ "Back_day"];

}

Else

{

[Self.backimage setimage:[uiimage imagenamed:@ "Back_day"];

}

}

-(void) Viewdidappear: (BOOL) animated

{

=================================== Loading a custom tab bar from the nib ======================================

[[NSBundle Mainbundle] loadnibnamed:@ "Maincontroller" owner:self Options:nil];

Self.tabBarController.view.frame = CGRectMake (0, 20, 320, 460);

Check network if no network will pop up prompt

if (iosexcept.network = = 0)

{

Uialertview *alert = [[Uialertview alloc]initwithtitle:@ ' network status ' message:@ ' no network connection ' delegate:self Cancelbuttontitle:nil otherbuttontitles:@ "OK", nil];

[Alert show];

[Alert release];

}

Else

{

Load data on the Internet

If connected to the network recommended interface #define KDATARECOMMENDLISTURL [Nsurl urlwithstring:@ "http://iphonenew.ecartoon.net/book_list.php?type=4"]

Self.recommenddata = [NSData Datawithcontentsofurl:kdatarecommendlisturl];

Serial Update Interface # define KDATASERIALIZEUPDATELISTURL [Nsurl urlwithstring:@ "http://iphonenew.ecartoon.net/book_list.php?type=3"]

Self.serialdata = [Nsmutabledata Datawithcontentsofurl:kdataserializeupdatelisturl];

[Iosexcept parsehotwordsxmlwithobjecthotswordsarray];//Popular Vocabulary analysis

Self.welcomeActivity.hidden = YES;

[Self entermaincontroller];//into five modules

}

}

//{

reachability *r = [reachability reachabilitywithhostname:@ "www.apple.com"];

//

switch ([R Currentreachabilitystatus]) {

Case Notreachable:

NSLog (@ "no network");

Break

Case Reachableviawifi:

NSLog (@ "WiFi network");

Break

Case Reachableviawwan:

NSLog (@ "WAN network");

Break

Default

Break

//    }

reachability Detecting Network status

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.