I wrote a GPS application for the iPhone and it all works well but now I want to send latitude and longitude Server on the Internet in the most simple way ... I have a URL from the server that has parameters for latitude and longitude, apart from that I want latitude and long. For every 90 seconds or so, how is this all done? Any help is greatly appreciated, thanks in advance!
ns URL * cgiUrl = [NSURL URLWithString: @ "http://yoursite.com/ Yourscript? Yourargs = 1 "]; NSMutableURLRequest * postRequest = [NSMutableURLRequestRequest URL: cgiUrl]; / * Leave only one GET * / NSSTING * PostBody = @ "Your postcode = 1"; NSString * contentType = @ "application / x-www-form-urlencoded; charset = utf-8"; Int contentLength = [postbodi length]; [PostRequest addValue: contentType forHTTPHeaderField: @ "content-type"]; [PostRequest addValue: [NSString stringWithFormat: @ "% d", contentLength] forHTTPHeaderField: @ "content-length"]; [PostRequest set HTTP system: @ "post"]; [PostRequest set HTTPBD: [postboard dataupting encoding: NSUTF 8 string encoding]]; / * Even here - line request below * / NSURL connection * conn = [with NSURL connection connection. Request: postRequest rep: self]; The data has been handled and accessed using it:
- (zero) connectionDifffish: Loading: (NSURLConnection *) connection {// data is full response} - (zero) connection: (NSURLConnection *) connection was reception: (NSURLResponse *) response {contentLength = [required contact lamp]; } - (Zero) Connection: (NSURLConnection *) connection was Resubmission: (NSDT * *) newdata {[DataApendance: New Data]; } - (zero) connection: (NSURLConnection *) connection does filewidth error: (NSError *) error {} You need to set up some variables, such as data, content length e.t.c. But it's general outline for HTTP interactions.
You may want to place all the handling stuff in a different handler class, I have changed the representative to self , so it is more self-contained.
: 90 Goal: Self Selector: @Sylector (XmitCoords) userInfo: Zero repeats: Yes];
Comments
Post a Comment