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

  • Home
  • SEARCH
  • 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 530537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:12:25+00:00 2026-05-13T09:12:25+00:00

I have an app with a tab bar and 3 tabs. The current location

  • 0

I have an app with a tab bar and 3 tabs. The current location of the user is going to be needed to be known on any of the three tabs. Would the best place to implement CLLocationManager be in the app delegate in this case?

Is it ok (good practise?) to put the CLLocationManager delegate methods in the app delegate m file?

Where would you suggest i place the CLLocationManager as I’m going to be calling -startUpdatingLocation from any of the three tabs?

Thanks

  • 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-13T09:12:25+00:00Added an answer on May 13, 2026 at 9:12 am

    The app delegate is a reasonable place to put it. Another option would be to create a custom singleton factory class that has a class method that returns your location manager delegate and implement the delegate methods there. That would keep your app delegate class cleaner.

    Here’s a skeleton singleton class implemention based off of Peter Hosey’s “Singletons in Cocoa: Doing them wrong”. This may be overkill, but it’s a start. Add your delegate methods at the end.

    static MyCLLocationManagerDelegate *sharedInstance = nil; 
    
    + (void)initialize {
        if (sharedInstance == nil)
            sharedInstance = [[self alloc] init];
    }
    
    + (id)sharedMyCLLocationManagerDelegate {
        //Already set by +initialize.
        return sharedInstance;
    }
    
    + (id)allocWithZone:(NSZone*)zone {
        //Usually already set by +initialize.
        @synchronized(self) {
            if (sharedInstance) {
                //The caller expects to receive a new object, so implicitly retain it
                //to balance out the eventual release message.
                return [sharedInstance retain];
            } else {
                //When not already set, +initialize is our caller.
                //It's creating the shared instance, let this go through.
                return [super allocWithZone:zone];
            }
        }
    }
    
    - (id)init {
        //If sharedInstance is nil, +initialize is our caller, so initialze the instance.
        //If it is not nil, simply return the instance without re-initializing it.
        if (sharedInstance == nil) {
            if ((self = [super init])) {
                //Initialize the instance here.
            }
        }
        return self;
    }
    
    - (id)copyWithZone:(NSZone*)zone {
        return self;
    }
    - (id)retain {
        return self;
    }
    - (unsigned)retainCount {
        return UINT_MAX; // denotes an object that cannot be released
    }
    - (void)release {
        // do nothing 
    }
    - (id)autorelease {
        return self;
    }
    #pragma mark -
    #pragma mark CLLLocationManagerDelegateMethods go here...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Tab bar App with four tabs. Each tab loads the same
my app starts with a tab bar controller which have 5 tabs. At start
I have an app that uses a tab bar controller. It has five tabs.
I have a tab-Bar Controller + UINavigation Controller app. In tabs 1,2,3 I have
I have a tab bar app with 4 tabs and nothing spectacular in the
I have an app with a tab bar controller (2 tabs). In one tab
I have multiple tabs (more than 5) in the tab bar in my app,
I have an app with a tab bar with two tabs. One tab displays
I have an tab bar app and the 2 tabs use the same class
If I have a tab bar app, and plan on using Core Location in

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.