views:

168

answers:

1

I need to access the users location in this method contained in the mainViewController

-(void)loadAnnotations{
[mapView removeAnnotations:mapView.annotations];

CLLocationCoordinate2D workingCoordinate;
workingCoordinate.latitude= //here i need the users latitude
workingCoordinate.longitude= //here i need the users longitude
NSLog(@" this is %@", workingCoordinate.latitude);
iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate];
[tempMine setTitle:@"Present Location"];
[tempMine setAnnotationType:iProspectLiteAnnotationTypeUser];
[mapView addAnnotation:tempMine];
}

however the mainViewController is already set to

<fipsideViewControllerDelegate>

What should I add to the header file and the implementation file to poll the location Manager for the users current latitude and longitude?

+1  A: 

In your other question I already told you how to get the location, so:

-[CLLocation coordinate]

It never hurts to look in the documentation before posting questions...

Dave DeLong
So I just type that into the loadAnnotations method? I have looked at the documentation, but its like looking for a needle in a haystack. So many unnecessary things, and they all set the locationManager delegate to self, which I cant do because the class is set to delegate the flipsideViewController
kevin Mendoza
oh wow, i feel retarded now lol. simple misunderstanding of syntax.
kevin Mendoza
however, now the program keeps crashing somewhere here:CLLocation *location = [locationManager location]; [mapView removeAnnotations:mapView.annotations]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; CLLocationCoordinate2D workingCoordinate = [location coordinate]; NSLog(@" this is %@", workingCoordinate.latitude);
kevin Mendoza
@Kevin don't use %@ to log a double...
Dave DeLong