nsdocumentdirectory

NSDocumentDirectory files disappear in ios

萝らか妹 提交于 2019-12-05 17:48:21
I want to save a mp4 video in my folder but when I open again the app, this file is nil. But when I save the file, I can open it, so it seems that it disappears from the folder. Save: NSData *videoData = [NSData dataWithContentsOfURL:exportUrl]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *tempPath = [documentsDirectory stringByAppendingFormat:@"/%@",videoName]; self.path_video_to_save = tempPath; BOOL success = [videoData writeToFile:tempPath atomically:YES]; if (success)

MPMoviePlayerController doesn't play from Documents folder

Deadly 提交于 2019-12-05 02:00:07
问题 Desperated. Hello everybody! I am having some issues with MPMoviePlayerController. I've made it working with videos from NSBundle. But that's not what I need. I need to play it from Documents directory, because that is the place I store the recorded videos, wich URLs are stored in CoreData. but lets leave this aside, and simplify the code to its minimum needed. This code actually WORKS if using the contentURL, wich leads to NSBundle. After it, what I do to get to the docs place. What I do:

How to delete all the files under my app's NSDocumentsDirectory?

吃可爱长大的小学妹 提交于 2019-12-04 17:37:20
I tried using NSString *DocumentsDirectoryPath = //Code to fetch the Documents Directory Path; NSError *error; NSFileManager *manager = [NSFileManager defaultManager]; [manager removeItemAtPath:DocumentsDirectoryPath error:&error]; The above code deletes the whole Documents directory of my app, but I just want to delete contents of the Documents directory not the Documents directory itself. What should I do? Rayfleck NSString *docsDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]; NSFileManager *localFileManager=[[NSFileManager alloc] init]; NSDirectoryEnumerator *dirEnum =

iOS - Saving multiple images to Documents folder

那年仲夏 提交于 2019-12-04 14:22:51
I have this code this code to save an image to the Documents folder. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:@"savedImage.png"]; UIImage *image = imageView.image; // imageView is my image from camera NSData *imageData = UIImagePNGRepresentation(image); [imageData writeToFile:savedImagePath atomically:NO]; I am looking for a way to be able to save multiple images as this one keeps over writing the

How to get the list of directores in NSDocumentDirectory?

六眼飞鱼酱① 提交于 2019-12-04 12:38:06
问题 I have created some directories in NSDocumentDirectory as if (![tbxCreateFolder.text isEqualToString:@""]) { NSArray *arrPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectoryStr = [arrPaths objectAtIndex:0]; // Get documents folder NSString *dataPath = [documentsDirectoryStr stringByAppendingPathComponent:[NSString stringWithFormat:@"/%@",tbxCreateFolder.text]]; if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]){

iPhone SDK Xcode - How to get all the filenames in the documents dir

£可爱£侵袭症+ 提交于 2019-12-04 11:28:58
问题 I want to get all the filenames in my application's documents folder, and place them in an NSMutableArray . Nothing more, nothing less. 回答1: There is a convenient method in NSFileManager : NSFileManager *fileManager = [[NSFileManager alloc] init]; NSArray *files = [fileManager contentsOfDirectoryAtPath:documentsDirectory error:nil]; ... [fileManager release]; As of ARC you can of course drop the release statement. 来源: https://stackoverflow.com/questions/7064190/iphone-sdk-xcode-how-to-get-all

Attach a video in SKPSMTPMessage

爷,独闯天下 提交于 2019-12-04 05:07:01
问题 I have a VideoClip.mp4 stored in my documents directory in my app. I can successfully send an email with SKPSMTPMessage, (email, subject, body, ect.) but I am having trouble attaching the video. I have already searched around a lot, but I will keep looking. If anyone can help me, that would be appreciated very much. Thank you! This code (apparently) attaches an image, but I haven't been able to figure out how to manipulate it to attach a video: NSString *image_path = [[NSBundle mainBundle]

MPMoviePlayerController doesn't play from Documents folder

怎甘沉沦 提交于 2019-12-03 16:21:47
Desperated. Hello everybody! I am having some issues with MPMoviePlayerController. I've made it working with videos from NSBundle. But that's not what I need. I need to play it from Documents directory, because that is the place I store the recorded videos, wich URLs are stored in CoreData. but lets leave this aside, and simplify the code to its minimum needed. This code actually WORKS if using the contentURL, wich leads to NSBundle. After it, what I do to get to the docs place. What I do: NSURL *contentURL = [[NSBundle mainBundle] URLForResource:@"Oct_08_2012_10_00_51" withExtension:@"mp4"];

Files disappearing from NSLibraryDirectory

我们两清 提交于 2019-12-03 14:04:57
问题 I'm storing some files in the Library directory in an iOS app, using the following methods to construct it. In the end, I can call [MyClass dataDirectory] to do my file handling and all is well. I've recently discovered, however, that some files seem to be mysteriously disappearing out of this directory. According to the documentation, this should not be the case. Is this a safe place to store persistent files? The console output of this directory is: ~/var/mobile/Containers/Data/Application/

Saving Array to Plist file that contains Custom Objects iPhone

江枫思渺然 提交于 2019-12-03 10:20:25
问题 I have a class called XYZ inheriting from NSObject and an array which contains objects of XYZ. I need to write this array to a plist file on to documents directory. After trying [array writeToFile....], I found that writeToFile fails because the array contains custom objects of XYZ class. The possible solution to this is to convert the objects to NSData. What are the different ways of achieving this?? I found that NSCoding is suitable but cant understand how to use it. Any help will be