2012-11-20 3 views
1

안녕하세요, 버튼에서 유닉스 명령을 실행하는 데 문제가 있습니다.버튼에서 유닉스 명령 실행 - XCode 목표 - C

이것은 내가 지금까지 무엇을 가지고 : 누군가가 도움을 줄 수있는 경우

> #import <Cocoa/Cocoa.h> 
> 
> @interface PUPController : NSWindow { } 
> - (IBAction)OpenPUP:(id)PUPC; 
> - (IBAction)DestinationFolder:(id)PUPC; 
> - (IBAction)Exit:(id)PUPC; 
> - (IBAction)Unpack:(id)PUPC; 
> 
> @end 
> 
> #import "OPDFPUE.h" 
> 
> @implementation PUPController 
> 
> - (IBAction)OpenPUP:(id)PUPC; { 
>  NSArray* fileTypes = [[NSArray alloc] initWithObjects:@"PUP", nil]; 
>  NSOpenPanel* openDlg = [NSOpenPanel openPanel]; 
>  [openDlg setCanChooseFiles:YES]; 
>  [openDlg setCanChooseDirectories:NO]; 
>  [openDlg setAllowsMultipleSelection:NO]; 
>  [openDlg setMessage:@"Select Playsation 3 System Software Update (PUP) File for Extraction"]; 
>  if ([openDlg runModalForTypes:fileTypes] == NSOKButton) 
>  { 
>   NSArray* files = [openDlg filenames]; 
>  } 
>  NSString * tvarDirectory = [openDlg directory]; 
>  NSString * tvarFilename = [openDlg filename]; } 
> 
> - (IBAction)DestinationFolder:(id)PUPC; { 
>  NSSavePanel *saveDlg = [NSSavePanel savePanel]; 
>  [saveDlg setMessage:@"Select folder to save extracted contents of the Playsation 3 System Software Update (PUP) File selected"]; 
>  int tvarInt = [saveDlg runModal]; 
> 
>  if(tvarInt == NSOKButton){ 
>  } 
>  else if(tvarInt == NSCancelButton) { 
>  return; 
>  } 
>  else { 
>  return; 
>  } 
>  NSString * tvarDirectory = [saveDlg directory]; 
>  NSString * tvarFilename = [saveDlg filename]; } 
> 
> - (IBAction)Exit:(id)PUPC; { 
>  exit(0); } NSTask *pupunpack; 
> 
> - (IBAction)Unpack:(id)PUPC { 
>  
>  pupunpack=[[NSTask alloc] init]; 
>  [pupunpack setLaunchPath:@"/usr/bin/pupunpack"]; 
>  [pupunpack launch]; 
>  } 
>  
>  - (id)init { 
>  
>  } @end 

그게 좋은 것입니다. 기본적으로 내가하고있는 일은 파일을 삽입하고 대상을 설정 한 다음 프로그램이 해당 파일을 압축 해제하는 것입니다. 강아지 파일을 선택하는 열린 대화 상자가 있고 저장 대상을 선택하는 저장 대화 상자가 있습니다. 나는 현재 아무 것도하지 않는 풀기 버튼을 가지고있다. 압축 해제 버튼에는 인수가 필요합니다. 누구라도 도움이된다면 도움이 될 것입니다.

저는 Objective-C를 처음 접했고, 이것에 관해서 많은 정보를 찾으려고했지만, 제대로 작동하지 않는 것 같습니다. 다음은 내가 사용하고있는 유닉스 애플리케이션이다.

https://dl.dropbox.com/u/43729201/pupunpack.zip

답변

0

당신은 아마 명령 인수로 파일 이름과 대상 디렉토리를 추가해야합니다

[pupunpack setArguments:[NSArray arrayWithObjects:tVarFilename, tvarDirectory, nil]]; 
+0

좋아, 나는했지만, 난 "식별자가"나는했습니다 – HamishClaxton

+0

를 말하는 오류가 발생했습니다 코드를 편집했습니다. –

+0

이제 선언되지 않은 식별자 tvarFilename; tvarDirectory – HamishClaxton