Chinaunix首页 | 论坛 | 博客
  • 博客访问: 388594
  • 博文数量: 11
  • 博客积分: 6000
  • 博客等级: 准将
  • 技术积分: 911
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-26 13:24
文章分类

全部博文(11)

文章存档

2011年(1)

2009年(4)

2008年(6)

我的朋友

分类:

2008-10-27 14:11:12

需要引入
fopen与open都可以使用,在Application_Home/Documents/这个目录下是可以使用"写"的操作。


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
//creates paths so that you can pull the app's path from it

NSString *documentsDirectory = [paths objectAtIndex:0];
//gets the applications directory on the users iPhone

NSString *scoreFileName = @"/SavedScores";
//sets the name of the file name to be SavedScores

const char *scoreFile = [[documentsDirectory stringByAppendingString:scoreFileName] UTF8String]; //appends scoreFileName to the end of documentsDirectory & converts it to a const char so that fopen can deal with it.

/*
FILE * pFile;
if((pFile = fopen ( scoreFile , "w" )) != NULL) { //opens file & positions to beginning
fclose(pFile);
}
*/

int fd;

fd = open(scoreFile, O_APPEND | O_WRONLY, 0755);

close(fd);

这些代码仅仅为了测试,并不规范。
阅读(2479) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~