我正在尝试使用ipad上的sdcard reader从sdCard导入文件。从卡中导入mts文件时,我将它们转换为mov格式并将其保存到应用程序的文档目录中。如果我不调用下面提到的函数来获取日期,它会完全转换文件。当我在导入时调用此函数来获取视频文件的创建日期。它崩溃并给出以下堆栈跟踪....
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'couldn't fork: errno 35'
*** Call stack at first throw:
(
0 CoreFoundation 0x32fba64f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x35992c5d objc_exception_throw + 24
2 CoreFoundation 0x32fba491 +[NSException raise:format:arguments:] + 68
3 CoreFoundation 0x32fba4cb +[NSException raise:format:] + 34
4 Foundation 0x3582be8f -[NSConcreteTask launchWithDictionary:] + 2138
5 Foundation 0x3582af57 -[NSConcreteTask launch] + 22
6 IRVideoEditor 0x0002f917 +[IRVideoManager getCreatedDate:] + 358
7 IRVideoEditor 0x0002f65d +[IRVideoManager duplicateExists:] + 240
8 IRVideoEditor 0x0002d6c9 -[IRVideoEncoder wrapVideos] + 752
9 IRVideoEditor 0x00016d27 -[ImportVideoViewController importVideo] + 170
10 Foundation 0x357b0389 -[NSThread main] + 44
11 Foundation 0x358225cd __NSThread__main__ + 972
12 libsystem_c.dylib 0x36539311 _pthread_start + 248
13 libsystem_c.dylib 0x3653abbc start_wqthread + 0
)
terminate called after throwing an instance of 'NSException'
bellow是代码,我用来使用nstask获取日期
NSPipe * pipe = [NSPipe pipe];
task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/sh"];
NSArray *arguments = [NSArray arrayWithObjects:@"-c", [NSString stringWithFormat:@"stat -c %%y %@", filePath], nil]; // iPad stat
[task setArguments: arguments];
[task setStandardOutput:pipe];
[task setStandardError:[NSPipe pipe]];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(taskExited :) name:NSTaskDidTerminateNotification object:task]; [任务启动]; // [task waitUntilExit];
NSString * date = [[[NSString alloc] initWithData:[[pipe fileHandleForReading] availableData] encoding:NSASCIIStringEncoding] autorelease];
return date;