Creating an iPhone Daemon – Part 2
Here is part two of the blog series “Creating an iPhone Daemon”, for part one please click?this link
As I said in part 1, we will be creating the DLocationDelegate class.
With most daemons, you do a task like read a file, do something with that file, sleep for a certain amount of time, then check for file changes, and repeat the steps over again. Unfortunately, with GPS coordinates, we have to wait for the CoreLocation delegate to give us the coordinates. The thing about Objective-C and Apple’s Cocoa framework is that most of the classes depend heavily on delegates. This is also true when dealing with the CoreLocation APIs. So lets get coding.
So lets write the DLocationDelegate header file first, this will give us a good look at what is ahead
?.- (void)connectionDidFinishLoading:(NSURLConnection *)connection;
This is for the NSURLConnection object that will send the GPS coordinates to our server.
In part three of this tutorial we will create the DLocationDelegate.m file (the implementation file)
-Chris
转自 :http://chrisalvares.com/blog/30/creating-an-iphone-daemon-part-2/