Search code examples
objective-cfirebasegoogle-cloud-firestoregeopointsmkpointannotation

Save MKPointAnnotation to Firestore


I have [mkmapview annotations] which is array of MKPointAnnotation

I am trying to save ti to FireStore as array but is not accepted the MKPointAnnotation object

then I try to convert MKPointAnnotation to FIRGeoPoint but no luck

for (MKPointAnnotation *point in annotationsArray) {
        FIRGeoPoint *FirAnnotations;
        FirAnnotations = [FirAnnotations initWithLatitude:point.coordinate.latitude longitude:point.coordinate.longitude];
        NSLog(@"FirAnnotations: %@",FirAnnotations);
    }

annotationsArray is [mkmapview annotations]

always get null


Solution

  • i'am attempting to use the FirAnnotations pointer to call init but it's nil and i should be using the FIRGeoPoint there.

    for (MKPointAnnotation *point in annotationsArray) {
            FIRGeoPoint *FirAnnotations;
            FirAnnotations = [[FIRGeoPoint alloc] initWithLatitude:point.coordinate.latitude                                                longitude:point.coordinate.longitude];
            NSLog(@"annotations: %@",annotations);
    }