How can I deal with connection problem when I use NSData?

You will have to get the data through a NSURLConnection which will have a timeout value, as described in the URL Loading System Programming Guide This should give you a hint; the guide has more complete sample code: Create an NSURLRequest object with your desired URL and timeout value NSURLRequest *request = NSURLRequest requestWithURL:NSURL URLWithString:@"221.34.21.9" cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0; // Begin a connection using that request // Assign a delegate object that will get callbacks when things happen NSURLConnection *connection = NSURLConnection alloc initWithRequest:request delegate:self Delegate methods are described in the NSURLConnection Class Reference You are probably most interested in connection:didRecieveData and connection:didFailWithError.

You will have to get the data through a NSURLConnection, which will have a timeout value, as described in the URL Loading System Programming Guide. This should give you a hint; the guide has more complete sample code: // Create an NSURLRequest object with your desired URL and timeout value NSURLRequest *request = NSURLRequest requestWithURL:NSURL URLWithString:@"221.34.21.9" cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:15.0; // Begin a connection using that request // Assign a delegate object that will get callbacks when things happen NSURLConnection *connection = NSURLConnection alloc initWithRequest:request delegate:self; Delegate methods are described in the NSURLConnection Class Reference You are probably most interested in connection:didRecieveData and connection:didFailWithError.

Thanks very much. It helps a lot! – Jerry Mar 23 at 9:17.

You need to implement Internet Reacheability, from Apple Reaceability example. It is a test which will allow you to know if your internet connection is reachable.

One init method of NSXMLParser is initWithData:(NSData *data). My app will wait for that address's response forever. How can I solve this problem?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions