2011-09-07 84 views
0

我一直在尝试调用我已经存储到数据库中的地方的经度和纬度。我已经将存储类型设置为double。从核心数据调用坐标

在第一个视图控制器,我试图推坐标,并在日志中工作正常。

-(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]; 
} 

现在在DisplayAllMapViewController,日志似乎总是为空。我试着将解析实例设置为NSString,NSNumber,double,但它仍然不发送任何值。

-(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]; 


} 

请看看..谢谢

+0

什么时候loadOurAnnotations被调用?在DisplayAllMapViewController的viewDidLoad中? – Anna

+0

@安娜卡列尼娜是的,在viewDidLoad – Harvin

回答

0

DiscoverAllMapViewControllerviewDidLoad只要你做pushViewController情况是你设置了latxlongy属性之前。

pushViewController拨到的属性被设置(就在fvController release之前)。