Baub
Baub

Reputation: 5044

Can't Connect Error Message - iPhone

I have an iPhone application that relies heavily on communicating with an external server. How can I throw an error message when the connection to the server cannot be made or the connection is lost? I have two connections, one is a HTML Post and the other is a socket stream using NSStream.

A little bit of background - the application communicates to the server via HTML Post, then communicates with a local wifi device via socket stream, then back to the server via Post, then back to the device via socket stream.

Communication

Upvotes: 0

Views: 179

Answers (2)

Perception
Perception

Reputation: 80603

The Apple documentation has an example of displaying stream errors using an NSAlert. You can do something similar for your URL connection stream, though you did not provide enough information for a specific recommendation.

Upvotes: 0

Owen Hartnett
Owen Hartnett

Reputation: 5935

I'm not sure if you're looking to detect an error, or if you just want to notify the user if you do. If it is the latter, look at the UIAlert class, which you can use to post up a dialog-type view to the user. If the former, both http processing and NSStream have error returns - just check them in your code, and put up the UIAlert.

Upvotes: 1

Related Questions