2012-11-23 63 views
0

我已經從教程中鍵入以下代碼,我不能讓它工作... 它說:「沒有可見@interface爲'NSFilemanager'聲明選擇器..... 在[文件句柄seekToEndOfFile] [文件句柄寫數據:[結果行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

看看你的代碼好一點:)這個錯誤是顯而易見的。 – 2012-11-23 23:47:22

+0

我改變fileHandle到別的東西,它的工作!歡呼聲:-) – MHG

回答

1

,如果你改變它會幫助:

NSFileManager *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg]; 

到:

NSFileHandle *fileHandle = [NSFileHandle fileHandleForUpdatingAtPath:savedTextMsg]; 

注意變量的類型。

+0

hA!:-)或我錯過了什麼? – MHG