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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:16:46+00:00 2026-06-13T09:16:46+00:00

I have an objective C method which passes in a string and an integer

  • 0

I have an objective C method which passes in a string and an integer as its arguments. Inside of this method, I want to use a selector – the name of which is based upon the integer value I am passing in. For example, if the integer argument is 5, I want the selector to be named “buildXArrayIndex5” or if the integer argument is 3, I want the selector to be named “buildXarrayIndex3.” I am really at a loss for how to do this or if it is possible/reasonable. I am new to objective C, so I wrote out what I want to happen, but it is not working/valid code. But here it is:

- (void) startBuildingXArray:(int)senderID:(NSString *)moveTrackerObject {

NSString *methodNamePrefix = @"buildXArrayIndex";

NSString *realMethodName = [[NSString alloc]initWithFormat:@"%@%d",methodNamePrefix,   
senderID];

SEL realSelector = NSSelectorFromString(realMethodName);

[self realSelector: moveTrackerObject];

}

In the interface, I declared SEL realSelector; but I am getting an error without running this that says”no visible @interface declares the selector realSelector.” But I’m sure that this is not the only problem with this code. Can anyone tell me how to create the proper code for this or highlight a better approach?

  • 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-13T09:16:47+00:00Added an answer on June 13, 2026 at 9:16 am

    You need to call your selector using -performSelector: method, e.g.:

    [self performSelector:realSelector];
    

    Also if methods you want to call accept parameter you need to add a colon to selector name:

    NSString *realMethodName = [[NSString alloc]initWithFormat:@"%@%d:",methodNamePrefix, senderID];
    

    and call it:

    [self performSelector:realSelector withObject:moveTrackerObject];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is Objective-C, in Xcode for the iPhone. I have a method in main.m:
In Objective-C, if I have a method in which I allocate and initialize an
Suppose I have Objective C interface SomeClass which has a class method called someMethod
I am having some trouble with objective c on iPhone. I have this method
I have some code in objective-C which uses the 'mutableCopy' method to make a
I have an Objective C selector which returns integers. I have a C++ instance
I have an Objective-C method which uses some x and y values from an
If subclass in objective-c wants to override a super class's method, does it have
When I have NSString with /Users/user/Projects/thefile.ext I want to extract thefile with Objective-C methods.
I have some Objective-C code that looks like this: #define myVar 10 float f

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.