nsdocumentdirectory

How to create directory using Swift code (NSFileManager)

ⅰ亾dé卋堺 提交于 2019-11-30 11:17:20
问题 I'm having some trouble with converting Objective-C code to create a directory for Swift. Objective-C: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/MyFolder"]; if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) [[NSFileManager defaultManager] createDirectoryAtPath:dataPath

How to display all images from NSDocument directory

风流意气都作罢 提交于 2019-11-30 07:32:40
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++) { ALAssetRepresentation *representation = [[assetArray objectAtIndex:j] defaultRepresentation]; NSString*

How to create directory using Swift code (NSFileManager)

空扰寡人 提交于 2019-11-29 23:34:17
I'm having some trouble with converting Objective-C code to create a directory for Swift. Objective-C: NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents folder NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"/MyFolder"]; if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath]) [[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:&error]; Swift 5.0 let paths =

How to save a TIFF photo from AVFoundations captureStillImageAsynchronouslyFromConnection to a file with EXIF metadata on an iPhone (iOS)?

对着背影说爱祢 提交于 2019-11-29 22:43:43
问题 With this question I only ask for the possibilities I have with Xcode and iOS without external libraries. I am already exploring the possibility of using libtiff in another question. Problem I have been sieving stack overflow for weeks and found working solutions for every one of my problems on its own. I have 4 things that need to work: I need the RGBA data as it comes from the camera, no compression whatsoever I need as much metadata as possible, especially EXIF I need to save in TIFF

NSSearchPathForDirectoriesInDomains returns the wrong directory

做~自己de王妃 提交于 2019-11-29 17:50:47
问题 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

Apps must follow the iOS Data Storage Guidelines or they will be rejected in app that contains .sqlite3

两盒软妹~` 提交于 2019-11-29 08:58:33
I created an ebook app and my app contains a lot of images and pdf files I was putting the downloaded images in /Library/Caches and putting the pdf files and .sqlite3 file in /Documents now my app is rejected and this is the reason 2.23 Apps must follow the iOS Data Storage Guidelines or they will be rejected Is this means that I have to move all what in /Documents to /Library/Caches? If I let the .sqlite3 file in /Documents, will the app reject again? Thanks in advance. 2.23 means that you should only put stuff into /Documents that cannot be re-downloaded from the internet. i.e. user

Read a .txt file inside documents directory

北慕城南 提交于 2019-11-29 01:20:31
How can I read a .txt file inside documents directory? Can you show me code? NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"txtFile.txt"]; NSString *content = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:NULL]; You can also use NSFileHandle for writing data in file and save to document directory: You can follow: NSFileHandle 来源: https://stackoverflow.com/questions/6546563/read-a

Save file in document directory in swift 3?

五迷三道 提交于 2019-11-29 01:08:33
I am saving files in a document directory in swift 3 with this code: fileManager = FileManager.default // let documentDirectory = fileManager?.urls(for: .documentDirectory, in: .userDomainMask).first as String var path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String path = path + name let image = #imageLiteral(resourceName: "Notifications") let imageData = UIImageJPEGRepresentation(image, 0.5) let bool = fileManager?.createFile(atPath: path, contents: imageData, attributes: nil) print("bool is \(bool)") return true But as you can see, I am not

Delete files from directory inside Document directory?

爱⌒轻易说出口 提交于 2019-11-28 18:28:32
问题 I have created a Temp directory to store some files: //MARK: -create save delete from directory func createTempDirectoryToStoreFile(){ var error: NSError? let paths = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true) let documentsDirectory: AnyObject = paths[0] tempPath = documentsDirectory.stringByAppendingPathComponent("Temp") if (!NSFileManager.defaultManager().fileExistsAtPath(tempPath!)) { NSFileManager

Document directory path change when rebuild application

若如初见. 提交于 2019-11-28 11:10:39
I download the video file from url and save it in document directory with this path: let destination: DownloadRequest.DownloadFileDestination = { _, _ in let pathComponent = "pack\(self.packID)-\(selectRow + 1).mp4" let directoryURL: URL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let folderPath: URL = directoryURL.appendingPathComponent("Downloads", isDirectory: true) let fileURL: URL = folderPath.appendingPathComponent(pathComponent) return (fileURL, [.removePreviousFile, .createIntermediateDirectories]) } my video is downloaded and plays successfully. but