我有以下代码,并且我一直收到EXC_BAD_ACCESS错误。我发布了这个代码的更复杂的副本,但我将问题归结为以下代码:
#import <Foundation/Foundation.h>
#include <NetFS/NetFS.h>
int main(int argc, const char * argv[]){
@autoreleasepool {
NSURL * share = [NSURL URLWithString: @"smb://192.168.0.100/lib"];
NSURL * path = [NSURL URLWithString: @"/Users/bogdan/Network/Library/"];
CFURLRef share2 = (__bridge CFURLRef) share;
CFURLRef path2 = (__bridge CFURLRef) path;
NetFSMountURLSync(share2, path2, NULL, NULL, NULL, NULL, NULL);
}
return 0;
}
问题在于“NetFSMountURLSync”行,但我无法弄清楚问题是什么。我想我正在使用它,我删除了所有可能的选项。运行此操作后,共享将被挂载,但在此之后我就会收到错误。
答案 0 :(得分:0)
得到了它!显然,即使我不关心返回的挂载点,我仍然必须将一个变量传递给函数,以便它可以将它存储在那里。此代码有效:
int main(int argc, const char * argv[]){
@autoreleasepool {
NSURL * share = [NSURL URLWithString: @"smb://192.168.0.100/lib"];
NSURL * path = [NSURL URLWithString: @"/Users/bogdan/Network/Library/"];
CFURLRef share2 = (__bridge CFURLRef) share;
CFURLRef path2 = (__bridge CFURLRef) path;
CFArrayRef mountpoints = NULL;
NetFSMountURLSync(share2, path2, NULL, NULL, NULL, NULL, &mountpoints);
}
return 0;
}