2011-01-12 73 views

回答

3

首先,您只能写入应用程序Documents目录。

- (BOOL)createFileAtPath:(NSString *)path contents:(NSData *)contents attributes:(NSDictionary *)attributes 

的NSFileManager DOC here

+0

我这样做,但没有为空文件工作.. NSFileManager * fileManager = [[NSFileManager alloc] init]; \t \t \t 如果\t:{ \t \t \t [文件管理createFileAtPath:路径内容:无属性:无]([文件管理fileExistsAtPath路径]!); \t \t} \t \t [fileManager release]; – 2011-01-12 10:20:53

+0

你必须在里面放些东西。把一个独特的钥匙或东西。然后测试createFileAtPath返回的那个bool。当你访问这个文件时,看看它是否有这个密钥,并从中删除密钥并在其中写入其他数据。 – 2011-01-12 10:28:30

0

你可以做到这一点作为一个自定义生成步骤(这实际上是一个简单的shell脚本)。例如,只需添加touch yourfilename

相关问题