CLLocationManagerDelegateを使用していると思いますか?
したがって、新しい場所が見つかったら、このメソッドに送信します。
– (void)locationManager:didUpdateToLocation:fromLocation:
そこから、値をデータベースに書き込むメソッドを呼び出して、値をパラメーターとして渡すことができます。例えば:
– (void)locationManager:(CLLocationManager *)locationManager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)newLocation {
NSString *latitude = [NSString stringWithFormat:@"%f", newLocation.coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", newLocation.coordinate.longitude];
NSString *stringFromDate = [formatter stringFromDate: newLocation.timestamp];
[self myFuntionThatWritesToDatabaseWithLatitude:latitude longitude:longitude date:stringFromDate];
}
- (void)myFuntionThatWritesToDatabaseWithLatitude:(NSString *)latitude longitude:(NSString *)longitude date:(NSString *)stringFromDate {
// write to Database
}