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. Plist读取和写入iPhone
- 2. 在C++中读取和写入文件
- 3. 在Python中读取和写入文件
- 4. 在Haskell中读取和写入文件
- 5. 读取和写入文件
- 6. 读取和写入文件
- 7. 读取和写入文件
- 8. 写入和读取文件
- 9. 从本地文件中写入和读取iPhone
- 10. 写入和从文件中读取
- 11. C中的文件读取和写入
- 12. 从python中读取和写入文件
- 13. 从plist文件中写入和读取
- 14. 写入和读取文件中的PhoneGap
- 15. 正在读取和写入文件C++
- 16. 正在读取和写入文件
- 17. 在java中写入和读入文件
- 18. 在Android中的文件中写入和读取文件
- 19. 读取和写入文本文件
- 20. Java - 读取和写入文本文件
- 21. 无法读取/写入数据到.plist文件在iPhone中
- 22. 在黑莓中读取/写入文件
- 23. 在Python中读取/写入文件
- 24. 在c中读取/写入bmp文件
- 25. 在C中读取(/写入)文件#
- 26. 如何读取和写入文件
- 27. 读取和写入XLS文件
- 28. Hadoop:HDFS文件写入和读取
- 29. 读取和写入文件到java
- 30. 读取和写入XML文件
如何检查文件写入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