English 中文(简体)
• 如何在宏观申请中通过指挥线论点
原标题:how to pass command line argument in Mac Application

I have created a Command line tool application ( Xocde --> New App --> Command line tool) and its running without any problem, Now i want to run it through terminal and pass some command line argument, something like this

int main(int argc, const char * argv[])
{

    std::cout << "got "<<argc<<" arguments";

    for ( int i = 0; i<argc;i++){
        std::cout << "argument:"<<i<<"= "<<argv[i];
    }

//// some other piece of code 
}

(一) 终端机上一台

>open VisiMacXsltConverter --args fdafsdfasf i am getting output 

got 1 argumentsargument:0= /Applications/VisiMacXsltConverte

我想通过指挥线知道,通过这一论点的途径是什么。

最佳回答

为什么你们想用开放<>?

我会随行(如果你在您的钱中拿到这笔钱的话):

./VisiMacXsltConverter arg1 arg2 arg3 arg4

我希望我没有误解你的问题。

问题回答

如果你只使用一种(Hphen),这些数值就会变成一个挥发的用户违约词典(也将压倒整个过程的其他钥匙)。

<代码>/program - 第4条:

int main(int argc, const char * argv[])
{

    @autoreleasepool {
        NSLog(@"param = %@", [[NSUserDefaults standardUserDefaults] valueForKey:@"Param"]);        
    }
    return 0;
}

或你只想通过这些内容,并使用以下方法,给你一个安全局。

[[NSProcessInfo processInfo] arguments];




相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签