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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:30:20+00:00 2026-05-26T05:30:20+00:00

I am working on a command-line tool which would run the method – [NSMutableDictionary

  • 0

I am working on a command-line tool which would run the method

- [NSMutableDictionary setObject:(id)object forKey:(NSString *)key]

The value I want to pass as object is the the content of the string argv[4]… So the user would type:

mytool arg1 arg2 arg3 [NSString stringWithFormat:@"asd"]

Still, plain argv[4] is obviously a char*, so I can’t add that as an object.

Is there a way to turn that string with an object as its content in a plain object so I can pass it on the method above?

Being: Turn "[NSString stringWithFormat:@"asd"]" into [NSString stringWithFormat:@"asd"]?

Note: This applies to any Objective-C object, so I could also pass as argv[4] something like [NSArray arrayWithObjects:@"obj1", nil].

Thanks in advance.

  • 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-26T05:30:21+00:00Added an answer on May 26, 2026 at 5:30 am

    Here’s a brief example of converting C strings into classes and selectors at runtime.

    // I added arg5 and arg6 for the example
    // mytool arg1 arg2 arg3 NSString stringWithFormat: asd
    NSString *className = [[NSString alloc] initWithUTF8String:arg4];
    NSString *selectorName = [[NSString alloc] initWithUTF8String:arg5];
    NSString *argument = [[NSString alloc] initWithUTF8String:arg6];
    Class myClass = NSClassFromString(className);
    SEL mySelector = NSSelectorFromString(selectorName);
    
    // If arg5 is a class method
    [myClass performSelector:mySelector withObject:argument];
    // or if arg5 is an instance method
    id instance = [[myClass alloc] init];
    [instance performSelector:mySelector withObject:argument];
    

    That’s a simple example with three tokens: NSString, stringWithFormat:, and one argument. To handle more complicated cases, you need to write your own string parser. It shows you some possibilities, though.

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

Sidebar

Related Questions

I am working on a C++ based command line tool and I want to
I'm trying to run my Silverlight tests via a command line (eventually MSBuild) working
I am working on a GUI (Cocoa) for a command-line tool to make it
When I run the KRL command line tool from the KRL gem on Windows
I'm working on a command line application for Solaris, written in Java6. I'd like
I'm working on a Perl script. How can I pass command line parameters to
we are working on a model checking tool which executes certain search routines several
Is there a command line tool that is able to search docx file under
Am working on a command line python script - throughout the script, I have
I cannot create working copy from command line using svn utility if resulting full

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.