nsdocumentdirectory

How to get the list of directores in NSDocumentDirectory?

梦想的初衷 提交于 2019-12-03 09:06:16
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]){ NSError* error; if([[NSFileManager defaultManager] createDirectoryAtPath:dataPath

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

此生再无相见时 提交于 2019-12-03 08:24:24
I want to get all the filenames in my application's documents folder, and place them in an NSMutableArray . Nothing more, nothing less. 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-the-filenames-in-the-documents-dir

CFURLSetResourcePropertyForKey failed when disable data backup on NSDocumentDirectory

那年仲夏 提交于 2019-12-03 06:36:22
问题 I am trying to download image files and store in NSDocumentDirectory . In order to do so, I has to turn off data backup on iCloud and iTunes. Below are my codes: +(void)saveData:(NSData*)thedata:(NSString*)fileName { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:fileName]; NSFileManager *fileManager =

How to read pdf file from document directory in iPhone?

限于喜欢 提交于 2019-12-03 03:49:01
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 *pdfData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:@"http://www.msy.com.au/Parts

CFURLSetResourcePropertyForKey failed when disable data backup on NSDocumentDirectory

穿精又带淫゛_ 提交于 2019-12-02 20:13:51
I am trying to download image files and store in NSDocumentDirectory . In order to do so, I has to turn off data backup on iCloud and iTunes. Below are my codes: +(void)saveData:(NSData*)thedata:(NSString*)fileName { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:fileName]; NSFileManager *fileManager = [NSFileManager defaultManager]; [fileManager createFileAtPath:localFilePath contents:thedata attributes:nil]; /

Right place to store the application data in IOS

扶醉桌前 提交于 2019-12-01 07:28:41
问题 Currently i was saving my application data (Media) to the CacheDirectory i.e /var/mobile/Applications/BEAFC76C-C450-4A3A-9765-A0385A9580F3/Library/Caches and things were going fine. But recently i got a bug report that the application data has been deleted. When i searched over it, i got this Apple Doc. According to it, DocumentsDirectory should be the ideal place to store the User/Application data. Put user data in the /Documents/. User data is any data that cannot be recreated by your app,

Playing a Downloaded Video from the Documents Directory with Cocoa-Touch

家住魔仙堡 提交于 2019-11-30 21:38:24
I'm trying to get my app to play a video file that's been downloaded to the documents directory. I know the file is getting downloaded, but I can't seem to get the file to play, here is my code: -(IBAction)play{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"%@/piggy.m4v"]; NSURL *movieURL = [NSURL fileURLWithPath:path]; _player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; [self.view addSubview:

Playing a Downloaded Video from the Documents Directory with Cocoa-Touch

倾然丶 夕夏残阳落幕 提交于 2019-11-30 17:05:26
问题 I'm trying to get my app to play a video file that's been downloaded to the documents directory. I know the file is getting downloaded, but I can't seem to get the file to play, here is my code: -(IBAction)play{ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *path = [documentsDirectory stringByAppendingPathComponent:@"%@/piggy.m4v"]; NSURL *movieURL = [NSURL fileURLWithPath:path

How to display all images from NSDocument directory

南笙酒味 提交于 2019-11-30 13:32:16
问题 First i selected images from photo library to ALAsset Library and after that i stored images in document directory from ALAsset library path. i am using this code to store images in document directory from ALAsset Library.... Its working perfect... Now i want to display all images which are stored in document directory in table view.. how can i do this??? can anybody help me?? Code for importing images from ALAsset Library to NSdocument directory for (int j=0; j<[assetArray count]; j++) {

NSSearchPathForDirectoriesInDomains returns the wrong directory

风流意气都作罢 提交于 2019-11-30 12:33:13
I'm using NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) to get the application documents directory in my app, but the array that's returned contains only one object, and it's an unwritable, incorrect directory: /Users/me/Library/Application Support/iPhone Simulator/Documents I found this question which indicates that the problem is related to provisioning, but the answer says little more than that. So I guess I'm asking a duplicate question, but the answer to that question is insufficient, so I'm hoping to get an actual answer in this one. Hmm ... so one