Я использую следующий код в моем проекте Cocoa для вызова созданного мной скрипта.Сценарий находится в той же папке, что и проект, и даже отображается в папке «Ресурсы» в XCode.Правильный путь найден, но он все еще говорит о том, что путь недоступен.Помогите пожалуйста.
NSBundle *mainBundle=[NSBundle mainBundle];
NSString *path=[mainBundle pathForResource:@"script" ofType:@"sh"];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath: path];
NSLog (path);
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
[task setStandardError: pipe];
NSFileHandle *file = [pipe fileHandleForReading];
[task launch];
[task waitUntilExit];
NSData *data = [ddFile readDataToEndOfFile];
NSString *output = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
[f setNumberStyle:NSNumberFormatterDecimalStyle];
HDSpeed = [f output];
[f release];
[task release];
Вывод, который я получаю в отладчике:
2010-07-10 17:53:26.384 tester[5023:a0f] /Users/guest/Library/Developer/Xcode/DerivedData/tester-bhukztmqjwoqrwereagsshvtbfqx/Build/Products/Debug/tester.app/Contents/Resources/script.sh
2010-07-10 17:53:26.386 tester[5023:a0f] launch path not accessible