2011-01-12 49 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

相關問題