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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:20:54+00:00 2026-05-24T16:20:54+00:00

I have an appDelegate that init an instance of a class called LocationService. I

  • 0

I have an appDelegate that init an instance of a class called LocationService.
I just want to pass to this instance by init a method that this class will run.

I got this exception:

2011-08-16 20:38:15.233 WalklogAnywhere[8258:307] -[LocationService setBackgroundActionMethod:]: unrecognized selector sent to instance 0x17a740
2011-08-16 20:38:15.249 WalklogAnywhere[8258:307] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LocationService setBackgroundActionMethod:]: unrecognized selector sent to instance 0x17a740'
*** Call stack at first throw:
(
        0   CoreFoundation        0x314d0987 __exceptionPreprocess + 114
        1   libobjc.A.dylib       0x319a149d objc_exception_throw + 24
        2   CoreFoundation        0x314d2133 -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
        3   CoreFoundation        0x31479aa9 ___forwarding___ + 508
        4   CoreFoundation        0x31479860 _CF_forwarding_prep_0 + 48
        5   WalklogAnywhere       0x00004013 -[LocationService initWithBackgroundMethod:] + 206
        6   WalklogAnywhere       0x0000246b -[WalklogAnywhereAppDelegate application:didFinishLaunchingWithOptions:] + 110
        7   UIKit                 0x338dabc5 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 772
        8   UIKit                 0x338d6259 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 272
        9   UIKit                 0x338a248b -[UIApplication handleEvent:withNewEvent:] + 1114
        10  UIKit                 0x338a1ec9 -[UIApplication sendEvent:] + 44
        11  UIKit                 0x338a1907 _UIApplicationHandleEvent + 5090
        12  GraphicsServices      0x35d66f03 PurpleEventCallback + 666
        13  CoreFoundation        0x314656ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
        14  CoreFoundation        0x314656c3 __CFRunLoopDoSource1 + 166
        15  CoreFoundation        0x31457f7d __CFRunLoopRun + 520
        16  CoreFoundation        0x31457c87 CFRunLoopRunSpecific + 230
        17  CoreFoundation        0x31457b8f CFRunLoopRunInMode + 58
        18  UIKit                 0x338d5309 -[UIApplication _run] + 380
        19  UIKit                 0x338d2e93 UIApplicationMain + 670
        20  WalklogAnywhere       0x000021bb main + 70
        21  WalklogAnywhere       0x00002170 start + 40
)
terminate called after throwing an instance of 'NSException'

this is my app delegate class method that init the LocationService instance:

-(void) backgroundLocationUpdate {
    NSLog(@"location is updated in background");
}


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application
     didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.

    [self.window makeKeyAndVisible];
    locationService = [[LocationService alloc]
            initWithBackgroundMethod:@selector(backgroundLocationUpdate:)];
    [locationService startForegroundService];
    storageService = [[StorageService alloc] init];
    [self loadApplicationData];

    return YES;
}

And this is the LocationService class method:

-(id) initWithBackgroundMethod:(SEL)selector {
    self = [super init];
    if (self != nil) {
        self.locationManager = [[CLLocationManager alloc] init];
        self.locationManager.delegate = self;
        locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        self.backgroundActionMethod = selector;
    }
    return self;
}

Please help me guys.
Thanks a lot!

  • 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-24T16:20:55+00:00Added an answer on May 24, 2026 at 4:20 pm

    A selector is just a method’s name. It’s not related to a class, nor an instance of a class.

    If you want to have a kind of callback, using selectors, you’ll have to provide a target object as well as the selector.

    Then, invoke the selector to the target object, using the performSelector method, inherited from NSObject.

    For error checking, see the respondToSelector method.

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

Sidebar

Related Questions

I have some class initialized in Appdelegate, but when I get this class instance
I have an Obj-C method similar to this: -(void)getUserDefaults:(BOOL *)refreshDefaults { PostAppDelegate *appDelegate =
I have a problem with the init() method of a standard NSObject. I wrote
I'm developing for the iPhone, and I have a class DataManager , that is
I have a ConfiguracaoDaApp class in my project that is a NSManagedObject subclass. I
i have this array called favorites referenced in my app delegate. When i access
i have a application that will have multiple uiviewcontrollers, the navigation in the application
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
Have you managed to get Aptana Studio debugging to work? I tried following this,

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.