Objective c 在SQLite数据库中保存经度和纬度
我正在用Objective-C为iPhone创建一个地图应用程序。我知道如何获取用户的当前位置和目标位置。当用户旅行时,其坐标(纬度和经度)会发生变化Objective c 在SQLite数据库中保存经度和纬度,objective-c,cocoa-touch,ios,sqlite,mapkit,Objective C,Cocoa Touch,Ios,Sqlite,Mapkit,我正在用Objective-C为iPhone创建一个地图应用程序。我知道如何获取用户的当前位置和目标位置。当用户旅行时,其坐标(纬度和经度)会发生变化 如何在用户旅行时每五分钟将用户的纬度和经度保存到SQLite数据库中?您可以使用计时器并将时间间隔设置为300,如下所示 [NSTimer scheduledTimerWithTimeInterval:300 target:self selector:@selector(*savetodatabase*) userInfo:nil repeats
如何在用户旅行时每五分钟将用户的纬度和经度保存到SQLite数据库中?您可以使用计时器并将时间间隔设置为300,如下所示
[NSTimer scheduledTimerWithTimeInterval:300 target:self selector:@selector(*savetodatabase*) userInfo:nil repeats:YES];
制作一个每5分钟调用一次的函数并保存到数据库中
[NSTimer scheduledTimerWithTimeInterval:<(NSTimeInterval)ti> target:<(id)aTarget> selector:<(SEL)aSelector> userInfo:<(id)userInfo> repeats:<(BOOL)yesOrNo>]
注意:这里300是秒您可以使用NSTimer调用一个方法,它将添加lat和long do数据库
[NSTimer scheduledTimerWithTimeInterval:<(NSTimeInterval)ti> target:<(id)aTarget> selector:<(SEL)aSelector> userInfo:<(id)userInfo> repeats:<(BOOL)yesOrNo>]
[NSTimer scheduledTimerWithTimeInterval:目标:选择器:用户信息:重复:]
您可以使用计时器,在每5分钟调用一次SAVEDATABASEFILE方法后,我怀疑您是否真的希望每5分钟存储一次坐标。使用Core Location时,您订阅用户已更改位置的事件(您可以设置精度),以便在用户移动时收到通知,然后选择将坐标存储在数据库中。如果你没有得到事件,那么你知道用户没有改变位置。@Ciryon:你应该回答这个问题。这比使用NSTimer要好