I am currently working on a school project where I needed to do something similar to this...
I was placing longitude and latitude values in a database.
MAKE NOTE THAT THERE MAY BE MUCH SIMPLER WAYS TO DO THIS. I AM BY NO MEANS A "PRO" AT OBJECTIVE-C PROGRAMMING
There are going to be three things you need.
- a server in which you have access to.
- a PHP file that will write the data to the database.
- an NSURLConnection object;
I had placed the following code in one of the delegate methods for CLLocationManager.
The NSURLConnection object should look something like this:
//this is where I put the url for my PHP file
url = [[NSURL alloc] initWithString:[NSString stringWithFormat:@"http://www.example.com/folder/example.php"]];
urlRequest = [NSURLRequest requestWithURL:url];
connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
Of course the variables: url, urlRequest, and connection are declared in the header file like this
NSURL *url;
NSURLRequest *urlRequest;
NSMutableData *filedata;
NSURLConnection *connection;