Syed Absar
Syed Absar

Reputation: 2284

Create a Blank File If Not Already Exist?

I added a blank file to the application resources but it is not found in the build, how would i programmatically check and create a file if it doesn't already exist?

Upvotes: 3

Views: 4615

Answers (2)

Krumelur
Krumelur

Reputation: 32497

You can do this as a custom build step (which is in fact a simple shell script). For example, just add touch yourfilename

Upvotes: 0

Alex Terente
Alex Terente

Reputation: 12036

First of all you can write only to application Documents directory.

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

NSFileManager doc here

Upvotes: 3

Related Questions