nsfilemanager

How to check if a file exists in Documents folder?

坚强是说给别人听的谎言 提交于 2019-11-26 10:05:50
问题 I have an application with In-App Purchase, that when the user buy something, download one html file into the Documents folder of my app. Now I must check if this HTML file exists, so if true, load this HTML file, else load my default html page. How I can do that? With NSFileManager I can\'t get outside of mainBundle .. 回答1: Swift 3: let documentsURL = try! FileManager().url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true) ... gives you a file URL of the

Create a folder inside documents folder in iOS apps

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 08:40:23
问题 I just want to create new folders in the documents folder of my iPhone app. Does anybody know how to do that? Appreciate your help! 回答1: I do that the following way: NSError *error; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/MyFolder"]; if (![[NSFileManager defaultManager]

Storing images locally on an iOS device

瘦欲@ 提交于 2019-11-26 07:58:01
问题 Some iOS photo-related apps store images created with the app somewhere other than the photo library. For example Fat Booth shows a scrolling list of photos created with the app at app start-up. Note these photos are persisted w/o the user explicitly saving them to the photo library. What is the simplest way to save and persist images inside an iOS application? The only persistent stores I\'m familiar with are NSUserDefaults and the key chain. However I\'ve never heard of these used to store