IPhone Xcode programming check if server is online

My app needs to connect to the server, but sometimes when I test my app I don't have my server online, so the app stays stuck when opened. How can I check programmatically if the server is online? Is there something like ping so I can check the state of the server and then do normal work or not if it is disabled? Thanks!

+2


a source to share


2 answers


Check out the Apple Reachability example (you're encouraged to use it in apps presented in the App Store).



+4


a source


Use [NSURLRequest + requestWithURL:cachePolicy:timeoutInterval:]

with timeoutInterval. Then your NSURLConnectionDelegate will receive a callback if the request expires.



0


a source







All Articles