nsfilemanager

open PDF URL in iOS 8?

 ̄綄美尐妖づ 提交于 2019-12-12 00:39:39
问题 I have write this code to show pdf using UIDocumentInteractionController.But,I don't know how to search pdf at local directory and open in iOS 8 and below..Any help? let filename = history.invoiceLongDate // 01223642 if !filename.isEmpty{ let paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true) let docs = paths[0] let pathURL = NSURL(fileURLWithPath: docs, isDirectory: true) if #available(iOS 9.0, *) { let fileURL = NSURL(fileURLWithPath: "\(filename)_my

How to get date and filesize from a picture?

巧了我就是萌 提交于 2019-12-11 20:11:00
问题 If pictures are loaded into an app from a album, how is it possible to get the filesize in MB and the date of that picture displayed on a app like on the screenshot below? I know you can retrieve the filesize via a NSLog using the following code, but how can I get this into a string and also the date of that picture? NSLog(@"size of image in KB: %i",[UIImagePNGRepresentation(UIImage) length]); 回答1: Use CoreGraphics size_t imageSize = CGImageGetBytesPerRow(image.CGImage) * CGImageGetHeight

NSFileHandle writeData synchronously delaying main thread operations

旧时模样 提交于 2019-12-11 18:54:28
问题 I have a custom implementation of a logger, which logs the actions and operations in my app. A strong NSString reference is living in one of my Singleton Classes. I call a method named " -(void)writeToFile: (BOOL) rightNow ", whenever I need to log something. This method also lives in that Singleton class. Yes passed to rightNow , will trigger the immediate call to writeData: on NSFileHandle, forcing the NSString to be written to the file and emptying the NSString afterwards. No, will only

Downloaded an Audio file into File Manager need to play it from local path

*爱你&永不变心* 提交于 2019-12-11 18:12:26
问题 I am working in an audio player application, and also I am having a offline download option, when the user click the download button it should start download and save it into local. I have saved it using file manager URLSession. I have tried of taking and separating the destination url. I am using a jukebox third party for playing the song. the sample file location is file:///var/mobile/Containers/Data/Application/BBB9AF1C-D87C-4C40-9F29-AD89062A20E2/Documents/05-KARMA-YOGA.mp3 if let

Specifying documents directory as file output URL while working with Glimpse in Swift

为君一笑 提交于 2019-12-11 17:19:33
问题 I'm using Glimpse to record the contents of a UIView so it can save it to a file in the documents directory. I'm having trouble specifying a URL for the file output in the g.startRecording line in viewDidLoad. I'd like to have the return value from getDocumentsDirectory() set as the URL but placing the method name as the parameter does not work. I have also tried to use documentsDirectory and this does not work either and results in "Ambiguous use of 'startRecording" I am using Swift here is

Play m4a file from document Directory

北城余情 提交于 2019-12-11 16:48:21
问题 I would to play an m4a file but I'm getting an error in the console and the file won't play. Console prints: The operation couldn’t be completed. (OSStatus error 2003334207.) let url = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] print("File Location: ",url.path) if(FileManager.default.fileExists(atPath: url.path)) { do { audioPlayer = try AVAudioPlayer(contentsOf: url) guard let player = audioPlayer else { return } player.prepareToPlay() } catch let error { print

Not able to edit first byte of file using NSFileHandle

依然范特西╮ 提交于 2019-12-11 11:09:46
问题 In my app, I am using NSFileHandle to edit some file but it is not editing. Below is the code: with comments & logs output //Initialize file manager NSFileManager *filemgr; filemgr = [NSFileManager defaultManager]; //Initialize file handle NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath]; //Check if file is writable if ([filemgr isWritableFileAtPath:filePath] == YES) NSLog (@"File is writable"); else NSLog (@"File is read only"); //Read 1st byte of file NSData

NSBundleResourceRequest bundlePath

☆樱花仙子☆ 提交于 2019-12-11 11:07:16
问题 [UPDATE AT THE END OF THE QUESTION] I use to play some audio files in my app. I used to store the files in the app, but then I moved to On Demand Resources and NSBundleResourceRequest . I have an IBAction to play a random file, and since I moved to ODR , it is not working. The only thing I changed was NSString *bundleRoot = [[NSBundle mainBundle] bundlePath]; (line 3) NSBundleResourceRequest *request1; - (IBAction)randomPlay { NSString *bundleRoot = [[request1 bundle] bundlePath];

how to determine how much time needed when calling moveItemAtURL:toURL: or replaceItemAtURL:WithItemAtURL:

别来无恙 提交于 2019-12-11 09:42:37
问题 When moving file from one place to another, or when replacing file, I always use the methods moveItemAtURL:toURL: or replaceItemAtURL:WithItemAtURL: from NSFileManager . When calling these methods, I want to determine how much time needed, so that I can use the NSProgressIndicator to tell users how long it's going to take. Just like when you are moving file using OSX, it tells u how much time remaining. I have looked at the apple doc but couldn't find any information regarding this. Wondering

Get Files Inside a folder in Document directory in iPhone

邮差的信 提交于 2019-12-11 08:48:07
问题 I am new to iPhone, I made an app in which, i am downloading a book and storing it in a folder called book1Folder which is inside Document directory . now i wants name of all books in my array, there are 2 books inside a book1Folder but when i write this code it shows me array count is 3. Here is my code snippet, -(void)viewWillAppear:(BOOL)animated{ NSString *files; NSString *Dir=[self applicationDocumentsDirectory]; Dir=[Dir stringByAppendingPathComponent:@"book1Folder"];