我无法将参数转换为我的Cocoa应用程序的NSString格式.我这样启动我的应用程序:
open my.app --args a1 a2
Run Code Online (Sandbox Code Playgroud)
我尝试访问这样的参数:
const char *h_path_char = [[[[NSProcessInfo processInfo] arguments] objectAtIndex:1] fileSystemRepresentation];
const char *s_path_char = [[[[NSProcessInfo processInfo] arguments] objectAtIndex:2] fileSystemRepresentation];
NSString *h_path = [NSString stringWithUTF8String:h_path_char];
NSString *s_path = [NSString stringWithUTF8String:s_path_char];
NSLog(@"%s", h_path);
NSLog(@"%s", s_path);
Run Code Online (Sandbox Code Playgroud)
但是,Xcode抱怨NSLog以下警告:
转换指定类型"char",但参数的类型为"NSString".
我怎么能克服这个?
| 归档时间: |
|
| 查看次数: |
1975 次 |
| 最近记录: |