English 中文(简体)
如何在iPhone 程序启动前检查特定网站是否可连接网络? [重复]
原标题:How to check if the network connection is available for a particular site before the app launches in iPhone? [duplicate]

我正在开发一个基于网络的应用程序, 只有当我的服务器为特定主机服务时才需要启动该应用程序。 如果网络连接不可用, 我正计划显示一个重新启动应用程序的警告视图 。 我使用此选项 :

    NSURL *scriptUrl = [NSURL URLWithString:@"http://lmsstaging.2xprime.com"];
    NSData *data = [NSData dataWithContentsOfURL:scriptUrl];

    if (data != nil) {
//Launch my application
}
else {
//show an alert
}

但问题是,当我点击警示视图中的“ 好” 按钮时, 我希望我的应用程序退出。 这是这样做的正确方式吗? 有人可以建议其他选项来克服这一情形吗?

最佳回答

不存在“ 官方” 退出方式。 苹果建议您警告要说 : “ 此应用程序需要网络连接。 按主按钮退出 。 ”

问题回答

暂无回答




相关问题
C# Networking API s [closed]

Lately I ve been looking for a good networking API i could possibly use and/or reference some of the code within, but i have mere luck searching for some on Google/Bing. Hopefully somebody here has ...

Listen to a port that is in use [duplicate]

Possible Duplicate: Get connecting IP from specified ports that using by other program. If a port is used by a program, is there any way I can listen that port and get the connected IP on that ...

Twisted Spread suitable for multiplayer racing sim?

Do you think that Twisted Spread may be suitable (in terms of performance) for a multiplayer racing simulator? The rest of the application is based on Python-Ogre. Can Perspective Broker run upon (...

Optimizing a LAN server for a game

I m the network programmer on a school game project. We want to have up to 16 players at once on a LAN. I am using the Server-Client model and am creating a new thread per client that joins. ...

multicast ip address - blocked in call to recvfrom

i am writing a simple multicast application. i intend to run it on localhost. i have done the following: char *maddr; . . . sendfd = socket(...); struct sockaddr_in sasend; sasend.sin_family = ...

Java HTTPAUTH

我试图把桌面应用程序连接起来,我是同D.icio.us api @ Delicious Alan书写的,简单地向他们提供我的用户名和密码,并请他把书记上写给我......。

热门标签