2012-11-23 3 views
0

튜토리얼에서 다음 코드를 입력했는데 제대로 작동하지 않습니다 ... "NSFilemanager에 대해 표시 할 수없는 @interface가 선택기를 선언합니다 ..... 에 대해 에서 [파일 핸들 seekToEndOfFile] [핸들 writeData는 : [resultLine dataUsingEncoding : NSUTF8StringEncoding]] [핸들 closeFile] 섹션 ..파일 핸들 옵션이 올라 오지 않습니다

필자는 많은 많은 시간을 통해 간으로 문제가 어떤 생각 .. 감사 매트

- (IBAction)SaveText:(id)sender { 

NSString *resultLine =[NSString stringWithFormat:@"%@\n", 
         self.inputText]; 

NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask,YES)objectAtIndex:0]; 
// textMsg.text = docPath; 

NSString *savedTextMsg =[docPath stringByAppendingPathComponent:@"textMessage.csv"]; 

if (![[NSFileManager defaultManager] fileExistsAtPath:docPath]) { 
    [[NSFileManager defaultManager] 
    createFileAtPath:savedTextMsg contents:nil attributes:nil]; 
} 
NSFileManager *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg]; 
[fileHandle seekToEndOfFile]; 
[fileHandle writeData:[resultLine dataUsingEncoding:NSUTF8StringEncoding ]]; 
[fileHandle closeFile]; 

self.textMsg.text [email protected]""; 
NSLog(@"info saved"); 

}

+0

코드를 조금 더 잘 살펴보십시오. 실수는 분명합니다. –

+0

fileHandle을 다른 것으로 바꿨습니다. 환호 :-) – MHG

답변

1

당신이 변경된 경우 도움이 될 :

NSFileManager *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg]; 

에 :

NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg]; 

주 변수의 유형입니다.

+0

hA! :-) 또는 나는 무엇인가 놓치고있다? – MHG

관련 문제