Create an empty file if it no longer exists?

I added an empty file to the application resources, but it was not found in the assembly, how would I programmatically check and create a file if it does not already exist?

+3
source share
2 answers

First of all, you can only write to the application document directory.

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

NSFileManager doc here

+3
source

You can do this as a custom build step (this is actually a simple shell script). For example, just addtouch yourfilename

0
source

Source: https://habr.com/ru/post/1784919/


All Articles