读书人

Creating an iPhone Daemon Part 三

发布时间: 2012-09-29 10:30:01 作者: rapoo

Creating an iPhone Daemon Part 3

This is part three of the blog series “Creating an iPhone Daemon”, for part one please click?this link

In the last part of the series, we created the header file for our DLocationDelegate class, now lets create the implementation file (DLocationDelegate.h)

NSTimer *timer =  [[NSTimertimerWithTimeInterval:1800.0target:selfselector:@selector(startItAgain:)userInfo:nilrepeats:NO] retain];[[NSRunLoop currentRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];

The DLocationDelegate timer is set for 1800.0 seconds, which is 30 minutes. I found that 30 minutes does not drain the battery too much, but still has a good amount of readings just incase your iPhone is lost.

While this will get your DLocationDelegate class setup, we still have one more issue, and that is that the iPhone will go into a hard sleep after a minute of no use. We will fix this in an upcoming tutorial.


读书人网 >Iphone

热点推荐