001
001

Reputation: 65205

iPhone: How to send httprequest via button?

There is 1 button on a view screen, when the user clicks the button a httprequest is sent to http://domain.com/buttoninput.php?id=1

Thats it! Nothing is loaded on the screen! the page is only loaded in the background.

Upvotes: 0

Views: 491

Answers (2)

Sat
Sat

Reputation: 1626

Try this // URL string encoding

NSString *escapedUrl = [aURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

// create the request

 NSURLRequest *aRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:escapedUrl]cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; 

// create the connection with the request // and start loading the data

NSURLConnection *aConnection=[[NSURLConnection alloc] initWithRequest:aRequest delegate:self]; 

Upvotes: 1

Eiko
Eiko

Reputation: 25632

You probably (at least you should) load the data asynchronously. Upon finishing (your delegate methods are your best friends) evaluate the data your received and change your UI elements. Why would you expect anything to update automatically?

Upvotes: 1

Related Questions