nsdocumentdirectory

How to read pdf file from document directory in iPhone?

旧街凉风 提交于 2019-12-20 14:43:55
问题 Currently i am working in iPhone application, i have an pdf file in resource folder (Local pdf file) then i read that pdf file (paper.pdf) successfully, below i have mentioned read local pdf file for your reference. Example: CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("paper.pdf"), NULL, NULL); pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL); CFRelease(pdfURL); Then i have tried to store pdf file (from URL) in NSDocument directory, stored successfully. NSData

How to convert code objective c to Swift to save image?

丶灬走出姿态 提交于 2019-12-19 05:51:34
问题 I have seen this code in other post, for save pictures: // Create path. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Image.png"]; // Save image. [UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES]; An d I'm trying convert to swift for save a picture take with avfoundatioin but I dont know type NSDocumentDirectory and NSUserDomainMask here How

How to save file in the documents folder?

≯℡__Kan透↙ 提交于 2019-12-17 16:42:06
问题 I am trying to save data in the documents folder on iPhone 5.1 simulator. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"myData.json"]; if ([[NSFileManager defaultManager] isWritableFileAtPath:filePath]) { NSLog(@"Writable"); }else { NSLog(@"Not Writable"); } I've got always "Not Writable". Any idea? Please

App Updates, NSURL, and Documents Directory

霸气de小男生 提交于 2019-12-17 11:57:07
问题 I have an app in the app store that uses Core Data to persist much of the data. The exception is storing images. I store images in subdirectories to the Documents directory and store an NSURL reference to that image in the appropriate object attribute in the core data store. We have noticed that, when an update makes it to the app store, those images are not found, and thus don't display, using the references stored with the previous version of the app. Now, I have a suspicion that the

How to find NSDocumentDirectory in Swift?

徘徊边缘 提交于 2019-12-17 02:55:09
问题 I'm trying to get path to Documents folder with code: var documentsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory:0,NSSearchPathDomainMask:0,true) but Xcode gives error: Cannot convert expression's type 'AnyObject[]!' to type 'NSSearchPathDirectory' I'm trying to understand what is wrong in the code. 回答1: Apparently, the compiler thinks NSSearchPathDirectory:0 is an array, and of course it expects the type NSSearchPathDirectory instead. Certainly not a helpful error message.

How to delete files from a folder which is placed in documents folder

馋奶兔 提交于 2019-12-13 08:04:04
问题 I want to delete the files which are placed in a folder(inside documents folder) of documents directory. I just listed or displayed all those files on the table view , can anybody tell me how can i do this using commitEditingStyle: method. Please help me how can i achieve this.Thanks in advance. 回答1: You can use the below code to delete the file from document directory: NSError *error; NSFileManager *fileMgr = [NSFileManager defaultManager]; NSArray *paths =

Store and fetch documents in/from app documents folder

不羁岁月 提交于 2019-12-12 18:13:24
问题 Im writing a text editor app and im trying to store a NSString as NSData in files in the documents folder, for example i want to be able to store a file "myText.java". My code work on the Simulator. However, on the device a file seems to be created, but when I later try to load the data from the files i get nothing. Do i have to set some project setting to enable the documents directory on device or is my code wrong? Here is my store code: -(void) saveFile:(NSString*)file{ if (![file isEqual:

How to load a self-made TIFF image file from NSDocumentsDirectory

六眼飞鱼酱① 提交于 2019-12-12 05:59:23
问题 When trying to load files from the NSDocumentsDirectory of an iPhone, I cannot create the image source with the path string I have. I get the error message " <Error>: ImageIO: CGImageSourceCreateWithURL CFURLCreateDataAndPropertiesFromResource failed with error code -15. ", which is a kCFURLImproperArgumentsError . However, I cannot find what "proper" arguments might be. An example path would be: " /var/mobile/Applications/36D76BDF-72EC-4180-9246-CF1F50CF396C/Documents/2013080110555532Image

iOS load file from documents directory

不羁岁月 提交于 2019-12-12 05:11:29
问题 I'm creating a registration app. It has two tabs, one tab is the registration form for students to fill out, and the other gives the user the ability to update the form. I'm still pretty new to iOS development, as well as Objective-c. Currently I'm saving a .csv file that contains the form data in the documents directory, in hopes that the app user can pull that file off the iPad and open it in microsoft excel. Unfortunately I'm not an Apple Developer yet, so I am not able to test it with a

Problems deleting video from document directory

混江龙づ霸主 提交于 2019-12-12 04:43:39
问题 I am trying to delete a video from the document directory, but the video isn't deleting. Here is how I am trying to delete the video: //Delete Video NSError *error = nil; //NSData *videoData = [NSData dataWithContentsOfURL:self.finalURL]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/vid1.mp4"]; [[NSFileManager