ios-sim:如何访问我的iPhone应用程序中的命令行参数? [英] ios-sim: How to access command line arguments in my iPhone application?
问题描述
我使用了在 github 上发现的真棒ios-sim, a>。
它允许你通过命令行运行模拟器,它还允许你选择使用哪个模拟器(iphone或iPad)。
我可以毫无瑕疵地运行我的应用程序。但是,我不确定如何使用通过命令行传递给我的应用程序的参数。
有没有人这样做或知道如何做?
./ ios-sim launch iTest.app --family ipad --args argument1 argument2
pre>
如何在iPhone应用程序中访问argument1和argument2?
解决方案在main.m文件中可以打印参数:
int main(int argc,char * argv [ ])
{
int i;
for(i = 0; iNSLog(@%s,argv [i]);
}
@autoreleasepool {
...
...
}
}
I am making use of the awesome ios-sim found on github.
It allows you to run the simulator via the command line and it also allows you to select which simulator (iphone or iPad) to use.
I am able to run my application flawlessly with it. However, I am unsure how to use the arguments passed to my application via the command line.
Has anyone done this or knows how to do this?
./ios-sim launch iTest.app --family ipad --args argument1 argument2
How do I access argument1 and argument2 in the iPhone application?
解决方案in the main.m File you can print the arguments with:
int main(int argc, char *argv[]) { int i; for (i = 0; i < argc; i++) { NSLog(@"%s", argv[i]); } @autoreleasepool { ... ... } }
这篇关于ios-sim:如何访问我的iPhone应用程序中的命令行参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!