【发布时间】:2014-08-26 13:00:39
【问题描述】:
我在下面的代码部分使用saveEventually。问题是,当应用程序被最小化并重新打开时,saveEventually 不起作用,只有当应用程序完全关闭并重新打开时。有什么办法可以解决吗?
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
// Generate Random Number
int random = arc4random_uniform(1000000000);
// Updates Location
NSLog(@"Location: %@",newLocation);
CLLocation *curentLocation = newLocation;
if (curentLocation != nil) {
// Submit through Parse
PFObject *object = [PFObject objectWithClassName:@"Issue"];
object[@"ID"] = [NSString stringWithFormat:@"%i",random];
object[@"Latitude"] = [NSString stringWithFormat:@"%.8f",curentLocation.coordinate.latitude];
object[@"Longitude"] = [NSString stringWithFormat:@"%.8f",curentLocation.coordinate.longitude];
object[@"Signal"] = [NSString stringWithFormat:@"%@",_avgNumber];
[object saveEventually];
// Update Text Fields
self.latitude.text = [NSString stringWithFormat:@"%.8f",curentLocation.coordinate.latitude];
self.longitude.text = [NSString stringWithFormat:@"%.8f",curentLocation.coordinate.longitude];
self.signal.text = [NSString stringWithFormat:@"%@",_avgNumber];
}
// Stop the Location Update
[manager stopUpdatingLocation];
}
【问题讨论】:
-
您没有使用 saveInBackground 有什么原因吗?
-
是的,由于它捕获的信息的性质,我的应用程序很可能会离线使用,因此 saveEventually 应该可以防止数据在离线时丢失。
标签: ios objective-c parse-platform