2011-03-10 2 views
0

각각 하나씩, XML 구문 분석을하고 있는데 내용이있는 서버에서 두 개의 텍스트 파일을 가져오고 있습니다. 두 번째로 내용을 덮어 쓰면 구문 분석시 첫 번째 파일 문서 디렉토리의 내용이 저장되었습니다 두 번째 파일, 나는 두 개의 서로 다른 내용iPhone 저장 파일

나는이 방법으로 첫 번째 파일의 내용을 촬영 한
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); 
     documentsDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Report.txt"]; 
     [text writeToFile:documentsDirectory atomically:NO]; 
     [text release]; 

의 문서 디렉토리에 두 개의 txt 파일을 생성하는 방법을 모르겠어요.

+0

문서 ** 디렉토리 **는 txt 파일의 경로입니다. –

답변

1

매번 다른 파일 이름을 제공하기 만하면됩니다. "REPORT.TXT"이외를 지정 ...

documentsDirectory = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Report.txt"]; 

... 줄에

즉를 :.

0

이 파일은 Documents 디렉터리에 파일을 저장할 고유 한 경로를 찾는 데 사용할 수있는 기능입니다.

새 고유 경로를 원할 때마다이 번호를 호출 할 수 있습니다.

- (NSString *)findUniqueSavePath{ 

    int i = 1; 
    NSString *path; 
    do { 
     // iterate until a name does not match an existing file 
     path = [NSString stringWithFormat:@"%@/Documents/txt_file_%03d.txt", NSHomeDirectory(), i++]; 
    } while ([[NSFileManager defaultManager] fileExistsAtPath:path]); 

    return path; 
}