문제

I have typed the following code in from a tutorial and i cannot get it to work... It says "No visible @interface for 'NSFilemanager' declares the selector ..... for the [fileHandle seekToEndOfFile]; [fileHandle writeData:[resultLine dataUsingEncoding:NSUTF8StringEncoding ]]; [fileHandle closeFile]; sections..

Any idea what the problem is as ive gone through it many many times.. Thanks Mat

 - (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 =@"";
NSLog(@"info saved");

}

도움이 되었습니까?

해결책

It would help if you changed:

NSFileManager *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg];

to:

NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg];

Note the variable's type.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top