ios-sim: How to access command line arguments in my iPhone application?

大兔子大兔子 提交于 2019-12-06 03:55:08

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 {
...
...
    }
}

You can use this to get the arguments:

[[NSProcessInfo processInfo] arguments];

I know this is an old question, but I thought I'd post it for future reference.

iOS doesn't support command-line access. This is from Apple's Cocoa Fundamentals Guide, Page 17 http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaFundamentals/WhatIsCocoa/WhatIsCocoa.html#//apple_ref/doc/uid/TP40002974-CH3-SW27

Generally, the system libraries and frameworks of iOS that ultimately support UIKit are a subset of the libraries and frameworks in Mac OS X. For example, there is no Carbon application environment in iOS, there is no command-line access (the BSD environment in Darwin), there are no printing frameworks and services, and QuickTime is absent from the platform. However, because of the nature of the devices supported by iOS, there are some frameworks, both public and private, that are specific to iOS.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!