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 543465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:33:16+00:00 2026-05-13T10:33:16+00:00

So my simple idea is to create an app that allows the user to

  • 0

So my simple idea is to create an app that allows the user to report their location’s latitude and longitude coordinates via email. You tap the button, the email screen comes up via the MessageUI framework, the To, Subject, and Body fields are already pre-entered, all that’s needed is for the user to hit “send”.

My problem, is that I need the latitude and longitude coordinates to be included in the email body. Those coordinate variables are generated in the -(void)CLLocationManager function and turned into strings, just like I need. The problem is, the email is being sent from another function, -(void)displayComposerSheet, and I can’t figure out how to get the lat / long strings into the body of the email to be sent. After pounding my way through Google for a bit, I’ve come across the idea of Global Variables. This seems like it’s what I need to implement. A lot of sources are saying “declare your variables in the app delegate and then you’ll be able to use them wherever in your code”, or at least that’s what I’m taking it to mean. Again, I’ll stress that I’m fairly new to this game. So, it seems that if I were to create my latitude and longitude strings in the delegate.m file instead of the project .m file, then I’ll be able to call upon them at my leisure and, presto, send them in my email’s body.

I’m just not exactly where all my “stuff” is supposed to go. Here’s what I’ve got so far (which works perfectly). I just need to replace my default latitude value of “12.3456” and longitude value of “78.9012” withe the ACTUAL values generated by CLLocationManager. Any help would be greatly appreciated. Thanks!

//Code that generates the Latitude and Longitude strings
//--------------------------------------------------------
- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation


{
    //Breaks down the location into degrees, minutes, and seconds.

    int degrees = newLocation.coordinate.latitude;
    double decimal = fabs(newLocation.coordinate.latitude - degrees);
    int minutes = decimal * 60;
    double seconds = decimal * 3600 - minutes * 60;
    NSString *lat = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
                     degrees, minutes, seconds];    
    latitude.text = lat;
    degrees = newLocation.coordinate.longitude;
    decimal = fabs(newLocation.coordinate.longitude - degrees);
    minutes = decimal * 60;
    seconds = decimal * 3600 - minutes * 60;
    NSString *longt = [NSString stringWithFormat:@"%d° %d' %1.4f\"",
                       degrees, minutes, seconds];
    longitude.text = longt;

}





//Code that prepares the email for sending
//------------------------------------------
-(void)displayComposerSheet 
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;

    [picker setSubject:@"New Location Report!"];


    // Set up recipients
    NSArray *toRecipients = [NSArray arrayWithObject:@"pghapps2009@gmail.com"]; 

    [picker setToRecipients:toRecipients];


    // Fill out the email body text 
    NSString *message = @"user reported their location at:";
    NSString *msgLat = @"12.3456";
    NSString *msgLong = @"78.9012";

    NSString *emailBody = [NSString stringWithFormat:@"%@\nLatitude = %@\nLongitude = %@", message, msgLat, msgLong];


    [picker setMessageBody:emailBody isHTML:NO];

    [self presentModalViewController:picker animated:YES];
    [picker release];
}
  • 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-13T10:33:16+00:00Added an answer on May 13, 2026 at 10:33 am
    //    NSString *msgLat = self->latitude.text; do not do this
    //    NSString *msgLong = self->longitude.text; or this
    NSString *msgLat = latitude.text;
    NSString *msgLong = longitude.text;
    

    No global variables needed (assume both methods belong to the same class).

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

Sidebar

Related Questions

Background: I am trying to create a really simple iPhone app that will allow
I'm trying to create a very simple stand-alone app that converts CATIA .dat files
I am attempting to create a simple app that can send a text message
I'm tryin to create a simple app that basically is a tracker that keeps
We are developing a web app that will have a pretty complex user and
Ok so I have a simple Android app that I want it to go
I'm developing a web-app where the user can create multiple related elements and then
I want to create a simple app for facebook, something like axa insurance They
I would like to create very simple program that could help my relative to
last year I made really simple blog system. it allows user to authorize, posting,

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.