开发者

calling coordinates from Core Data

开发者 https://www.devze.com 2023-04-03 03:57 出处:网络
i\'ve been trying to call the latitude and longitude of places that i have stored into the database. I\'ve set the storage type as double.

i've been trying to call the latitude and longitude of places that i have stored into the database. I've set the storage type as double.

At the the first view controller, i tried to push the coordinates, and in the log it works fine.

-(IBAction) mapsend:(id)sender
{
    DiscoverAllMapViewController *fvController = [[DiscoverAllMapViewController alloc] initWithNibName:@"DiscoverAllMapViewController" bundle:nil];
    [self.navigationController pushViewController:fvController animated:YES];
    double dx = [wher.latx doubleValue];
    double dy = [wher.longy doubleValue];

    fvController.latx =[NSString stringWithFormat:@"%f",dx]; 
    fvController.longy =[NSString stringWithFormat:@"%f",dy]; 
    NSLog(@"checking latx :%@",fvController.latx);
    [fvController release];
}

now at DisplayAllMapViewController, the log seems to always be null. I've tried setting the parsing instance to NSString, NSNumber, double, but it still doesnt send any value.

-(void)loadOurAnnotations
{
    CLLocationCoordinate2D workingCoordinate;
    MKCoordinateSpan span = {0.2, 0.2};
    double xx = [latx doubleValue];
    double yy = [longy doubleValue];
    NSLog(@"check latx :%f",xx);
    workingCoordinate.latitude = 开发者_开发技巧xx;
    workingCoordinate.longitude = yy;
    MKCoordinateRegion region = {workingCoordinate, span};
    DiscoverAllMapAnnotation *appleStore1 = [[DiscoverAllMapAnnotation alloc] init];
    [appleStore1 setCoordinate:workingCoordinate];
    [appleStore1 setTitle:@"Kota Kinabalu"];
    [appleStore1 setSubtitle:@"BOMB!!!!!"];
    [appleStore1 setAnnotationType:DiscoverAllMapAnnotationType1];

    mapView.showsUserLocation=TRUE;
    [mapView addAnnotation:appleStore1];
    [mapView setRegion:region];
    [appleStore1 release];


}

please have a look.. thank you


The viewDidLoad of DiscoverAllMapViewController happens as soon as you do pushViewController which is before you've set the latx and longy properties.

Move the pushViewController call to after the properties are set (just before the fvController release).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号