这是问题所在,当我使用 NSTask 卸载当前 USB 驱动器时,它会给我以下错误:
2013-06-03 09:39:41.096 NAME[1028:303] in moving file view controller
dyld: DYLD_ environment variables being ignored because main executable
(/usr/sbin/diskutil) has __RESTRICT/__restrict section
Unmount of disk1 failed: at least one volume could not be unmounted
我有我的mac分区,所以disk1我认为是mac os。这是我用来卸载驱动器的功能:
//When I call this function by passing all of these arguments:
NSArray* arrayForCloseUSBDrive = [[NSArray arrayWithObjects:@"diskutil", @"unmountDisk",@"/Volumes/AAA/",nil]autorelease];
[Utility handleDrive:@"/usr/bin/env" arrayArguments:arrayForCloseUSBDrive];
//It will start run this function in Utility class:
+(void)handleDrive:(NSString*)launchPath arrayArguments:(NSArray*)array
{
NSTask *task = [NSTask new];
[task setLaunchPath:launchPath];
[task setArguments:array];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
[task launch];
[task waitUntilExit];
}