Ok, so I have code that posts to my php site, but I want a way to make sure the data gets there. Is there way for the submision to hang intill it timesout or the server responds saying submission accepted?
Here is the code I have so far:
//Create String
NSString *var1 =@"waitTime=";
NSString *var2 =@"&cover=";
NSString *wait = [var1 stringByAppendingString:waitTime.text];
NSString *co = [var2 stringByAppendingString:cover.text];
NSMutableURLRequest *request =
[[NSMutableURLRequest alloc] initWithURL:
[NSURL URLWithString:@"http://mysite.net/index.php"]];
[request setHTTPMethod:@"POST"];
NSString *postString = [wait stringByAppendingString:co];
[request setValue:[NSString
stringWithFormat:@"%d", [postString length]]
forHTTPHeaderField:@"Content-length"];
[request setHTTPBody:[postString
dataUsingEncoding:NSUTF8StringEncoding]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
You can get the status code as explained in this link
Status codes are defined at this link.
201
Following a POST command, this indicates success, but the textual part of the response line indicates the URI by which the newly created document should be known.
Update
If the connection times out, you should see this when the connection:didFailWithError: delegate method is called.