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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T07:31:10+00:00 2026-06-01T07:31:10+00:00

I am completely new to iOS development so I may be doing this wrong

  • 0

I am completely new to iOS development so I may be doing this wrong but I have a class I am using to get coordinate gps data that I want to have as a generic class I can reuse in lots of apps. My problem is getting the data from the gps to properly display in other apps.

Here is my header file for the GPS class:

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@interface LocationAwareness : NSObject <CLLocationManagerDelegate> {
CLLocationManager *locationManager;
}
@property(copy) NSString *longitude;
@property(copy) NSString *latitude;

@end

And here is the implementation:

#import "LocationAwareness.h"

@implementation LocationAwareness
@synthesize longitude;
@synthesize latitude;


- (id)init {

locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
[locationManager startUpdatingLocation];
return self;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation   *)newLocation fromLocation:(CLLocation *)oldLocation {

    // Stops updating location if data has been updated within 10 minutes
    if ( abs([newLocation.timestamp timeIntervalSinceDate: [NSDate date]]) < 600) {

        [locationManager stopUpdatingLocation];
        float latitudedata = newLocation.coordinate.latitude;
        latitude = [NSString stringWithFormat:@"%f", latitudedata];

        float logitudedata = newLocation.coordinate.longitude;
        longitude = [NSString stringWithFormat:@"%f", logitudedata];

    }
}

@end

Now I can’t seem to find anywhere that tells me how to get the latitude or longitude properties in another project. I have the header imported and have tried to store LocationAwareness.latitude into a variable that I can use but everything I store it in ends up blank. When I start my main class and aloc init a locationawareness object the gps fires up so I think its working but I don’t seem to know enough about how this works to get everything in order. I’ve been searching the internet for hours. Anyone have an idea what I am doing wrong?

  • 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-06-01T07:31:12+00:00Added an answer on June 1, 2026 at 7:31 am

    Well, this may or may not be causing the problem (it’s quite likely), but a major problem is your init method.

    The beginning should be:

    self = [super init];
    if (self) {
        // Do your initializing as you did above.
    }
    return self;
    

    edit:
    I added your code with my update to a project and it works well.
    In order to use this, you should do something like the following:

    LocationAwareness *loc = [[LocationAwareness alloc] init];
    
    // Give it some time to start updating the current location and then
    // in a different function:
    NSLog(@"%@", loc.latitude);
    

    EDIT 2
    Wherever you are using this, you will want to declare a property which stores it so that you can create it once and reference it many times. To do that, use the following code:

    In the header for the object where you want to use this object, add this with the other properties:

    @property (nonatomic, assign) LocationAwareness *location;
    

    Then, towards the top of your implementation file (.m file) you should see other @synthesize lines, add this one:

    @synthesize location;
    

    Then, create the actual location instance that you want to use as per the example above:

    self.location = [[LocationAwareness alloc] init];
    

    Now give it some time to figure out your location and start providing updates. Then you can print the location like this:

    NSLog(@"%@", self.location.latitude);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am completely new to iOS development and I want to load another view
I think this is a new spin on an old question, but I'm completely
is there some new framework additions for doing something like this in iOS 4
I am completely new to iOS development (I'm a .NET dev). I am experimenting
I am completely new to ios development and I am only interested in developing
First off, I am completely new to iOS development, so I hope there is
I am new in ios development. I am doing a photo cropper app. I
I'm completely new to AIR but what I'm trying to do feels like it
I have an iOS project that sends a Person class with one attribute name
Im completely new to Java web stuff, but here goes my question: 1) How

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.