3
A
回答
7
写入文件:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// the path to write file
NSString *myFile = [documentsDirectory stringByAppendingPathComponent:@"myFile"];
[data writeToFile:myFile atomically:YES];
阅读文件:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"MyFile" ofType:@"txt"];
NSData *myData = [NSData dataWithContentsOfFile:filePath];
if (myData) {
// do something useful
}
相关问题
- 1. 在Haskell中读取和写入文件
- 2. 在C++中读取和写入文件
- 3. 读取和写入文件
- 4. 写入和读取文件
- 5. 正在读取和写入文件C++
- 6. 正在读取和写入文件
- 7. 从plist文件中写入和读取
- 8. 从python中读取和写入文件
- 9. 写入和从文件中读取
- 10. 在java中写入和读入文件
- 11. 读取和写入文本文件
- 12. 在C中读取(/写入)文件#
- 13. 在Python中读取/写入文件
- 14. Python快速读取和写入文件
- 15. 从csv文件读取和写入
- 16. 麻烦读取和写入文件c#
- 17. 读取和写入XML文件
- 18. 如何读取和写入文件
- 19. 如何读取和写入文件
- 20. 同时写入和读取文件
- 21. 文件读取,写入和保存
- 22. 使用mex读取和写入文件
- 23. 从文件读取和写入
- 24. PHP:读取和写入Excel文件
- 25. Python:读取和写入CSV文件
- 26. Node.js读取和写入文件行
- 27. 并发读取和写入文件
- 28. Robovm读取和写入文件
- 29. C++ fstream读取和写入文件
- 30. CakePHP读取和写入json文件。
如何检查文件写入iPhone设备上或不? – suse 2010-09-07 03:51:51
http://developer.apple.com/iphone/library/documentation/cocoa/reference/foundation/Classes/NSData_Class/Reference/Reference.html#//apple_ref/occ/instm/NSData/writeToFile:options:error:' writeToFile'返回“YES”或“NO”状态。 – ohho 2010-09-07 06:25:37