Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 729611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:48:59+00:00 2026-05-14T06:48:59+00:00

I have a detail view that includes three UIButtons, each of which pushes a

  • 0

I have a detail view that includes three UIButtons, each of which pushes a different view on to the stack. One of the buttons is connected to a MKMapView. When that button is pushed I need to send the latitude and longitude variables from the detail view to the map view. I’m trying to add the string declaration in the IBAction:

- (IBAction)goToMapView {

MapViewController *mapController = [[MapViewController alloc] initWithNibName:@"MapViewController" bundle:nil]; 

mapController.mapAddress = self.address;
mapController.mapTitle = self.Title;

mapController.mapLat = self.lat;
mapController.mapLng = self.lng;

//Push the new view on the stack
[[self navigationController] pushViewController:mapController animated:YES];
[mapController release];
//mapController = nil;

}

And on my MapViewController.h file I have:

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import "DetailViewController.h"
#import "CourseAnnotation.h"

@class CourseAnnotation;

@interface MapViewController : UIViewController <MKMapViewDelegate>
{
IBOutlet MKMapView *mapView;
NSString *mapAddress;
NSString *mapTitle;
NSNumber *mapLat;
NSNumber *mapLng;
}

@property (nonatomic, retain) IBOutlet MKMapView *mapView;
@property (nonatomic, retain) NSString *mapAddress;
@property (nonatomic, retain) NSString *mapTitle;
@property (nonatomic, retain) NSNumber *mapLat;
@property (nonatomic, retain) NSNumber *mapLng;

@end

And on the pertinent parts of the MapViewController.m file I have:

@synthesize mapView, mapAddress, mapTitle, mapLat, mapLng;

- (void)viewDidLoad 
{
    [super viewDidLoad];

[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];

MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };

region.center.latitude = mapLat; //40.105085;
region.center.longitude = mapLng; //-83.005237;

region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;  
[mapView setRegion:region animated:YES];

[mapView setDelegate:self];

CourseAnnotation *ann = [[CourseAnnotation alloc] init];
ann.title = mapTitle;
ann.subtitle = mapAddress;
ann.coordinate = region.center;
[mapView addAnnotation:ann];

}

But I get this when I try to build: ‘error: incompatible types in assignment’ for both lat and lng variables. So my questions are am I going about passing the variables from one view to another the right way? And does the MKMapView accept latitude and longitude as a string or a number?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:49:00+00:00Added an answer on May 14, 2026 at 6:49 am

    Latitude and longitude in MapKit are stored as CLLocationDegrees types, which is defined as double. To convert your NSNumbers to doubles, use:

    region.center.latitude = [mapLat doubleValue];
    

    Or, perhaps better, declare your properties as CLLocationDegrees from the start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a detail view that includes three UIButtons, each of which pushes a
Help!! I have a listadapter with a detail view, the problem that I am
I have two fragments, one a ListView and one a details view. Each fragment
Just an introduction of my code... I have a view that consists of -details
I have a UITabBar in the detail view of my navigation based application. I
I have a product listing page and want to load up a detail view
I am looking to make a Master Detail View. I have two tables tbFamily
In my iPhone Core Data app I have it configured in a master-detail view
When using a spilt view controller, I have a Master and Detail View. When
I am working on UISplitViewController, I have a pageController in my detail view of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.