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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:43:08+00:00 2026-06-18T18:43:08+00:00

I was trying to implement a separate class for managing my location. I wanted

  • 0

I was trying to implement a separate class for managing my location. I wanted to get my location whenever I click a button.

gpsFilter.h

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

@interface gpsFilter : NSObject <CLLocationManagerDelegate>

@property (nonatomic, retain) CLLocationManager *gpsManager;
@property (nonatomic, retain) NSString * latitude;
@property (nonatomic, retain) NSString * longitude;
@end

gpsFilter.m.

#import "gpsFilter.h"

@implementation gpsFilter

- (id) init{
self = [super init];
if(self != nil){
    self.gpsManager = [[CLLocationManager alloc] init];
    self.gpsManager.delegate = self;
    [self.gpsManager startUpdatingLocation];
    BOOL enable = [CLLocationManager locationServicesEnabled];
    NSLog(@"%@", enable? @"Enabled" : @"Not Enabled");
}
return self;
}

- (void)gpsManager:(CLLocationManager *) manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
NSLog(@"didUpdateToLocation: %@", newLocation);
CLLocation *currentLocation = newLocation;
if(currentLocation != nil){
    self.latitude = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.longitude];
    self.longitude = [NSString stringWithFormat:@"%.8f", currentLocation.coordinate.latitude];
}
}

- (void)gpsManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
NSLog(@"didFailWithError: %@", error);
}
@end

I am using a separate class because I wanted to add smoothing filter in the future. I don’t get any updates. The NSLog is never triggered. I think some variable is getting autoreleased, but I am not sure, which one.

The viewController code is as follows.

#import "gpstestViewController.h"

@interface gpstestViewController (){

}

@end

@implementation gpstestViewController


- (void)viewDidLoad
 {
[super viewDidLoad];
self.location = [[gpsFilter alloc] init];
// Do any additional setup after loading the view, typically from a nib.
}


- (IBAction)getloca:(id)sender {
self.latitudeLabel.text = [self.location latitude];
self.longitudeLabel.text = [self.location longitude];

}

- (IBAction)getLocation:(id)sender {
self.latitudeLabel.text = [self.location latitude];
self.longitudeLabel.text = [self.location longitude];

}
@end

I am sorry that I am dumping a lot of code, but I am a newbie to ios programming and I am not able to find what the problem is.

EDIT: The updateLocation delegate method is not being called at all.

  • 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-18T18:43:09+00:00Added an answer on June 18, 2026 at 6:43 pm

    The delegate methods must be named locationManager:didUpdateToLocation:fromLocation: and locationManager:didFailWithError:.

    You cannot use custom method names like gpsManager:didUpdateToLocation:fromLocation:.

    Also note that locationManager:didUpdateToLocation:fromLocation: is deprecated as of iOS 6 and you should use locationManager:didUpdateLocations:.

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

Sidebar

Related Questions

Puns aside, I'm trying to implement an import method in my Perl class to
Trying to implement 3-layer (not: tier, I just want to separate my project logically,
I am trying to implement a class in different cpp files. I understand it
I am currently trying to implement a serial port reader class using Windows (already
I am trying to implement a dialog box to appear when a button is
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I am trying implement a most recent widget into my tumblr post. So far,
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement a search similar to here .This searches properties based on city,locality,property

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.