nsfilemanager

FileManager cannot find audio file

三世轮回 提交于 2019-12-02 05:16:32
Helloo! My ultimate goal is to create a UITableViewController with recordings made in-app, using FileManager to traverse the /Documents/ directory and list all the recordings found there. The recording and playback are functioning just fine with one recording, with the following setup: // In VC#1 func setupRecorder(){ let audioSession:AVAudioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord) } catch { print("Audio Setup Error: \(error)") } do { try audioSession.setActive(true) } catch { print("Audio Setup Error: \(error)") } let

Can't play file from documents in AVAudioPlayer

爱⌒轻易说出口 提交于 2019-12-02 04:49:45
I have a file on documents folder of app and I want to play it. if NSFileManager.defaultManager().fileExistsAtPath(pathString) { let url = NSURL(fileURLWithPath:pathString, isDirectory: false) do { let player = try AVAudioPlayer(contentsOfURL:url) player.prepareToPlay() player.play() } catch let error as NSException { print(error) } catch {} } There is a file on file system and I checked its existence. Also all lines in do block are executed. There is neither exception nor error and still no sound is played. What are possible problems and how can I solve them? You should make audioPlayer an

Check if file on website exists

老子叫甜甜 提交于 2019-12-02 04:12:33
问题 on the iPhone I want to check, if a specific file (test.licence) on a website exsists. My approach (so far) was to download the file and check if it exists in my Documents directory. However, if the file does not exists, Apache presents a HTML error page (which I download instead of test.licence). Checking the file size is a fuzzy solution, since it varies. So, how do I check, if a online file exists (not more)? I'm looking for a simple yet clean solution. Regards, Stefan 回答1: Submit an

Cocoa - NSFileManager removeItemAtPath Not Working

随声附和 提交于 2019-12-02 00:34:28
问题 I am trying to delete a file, but somehow nsfilemanager will not allow me to do so. I do use the file in one line of code, but once that action has been ran, I want the file deleted. I have logged the error code and message and I get error code: 4 and the message: "text.txt" could not be removed Is there a way to fix this error "cleanly" (without any hacks) so that apple will accept this app onto their Mac App Store? EDIT: This is what I am using: [[NSFileManager defaultManager]

Cocoa - NSFileManager removeItemAtPath Not Working

空扰寡人 提交于 2019-12-01 20:23:54
I am trying to delete a file, but somehow nsfilemanager will not allow me to do so. I do use the file in one line of code, but once that action has been ran, I want the file deleted. I have logged the error code and message and I get error code: 4 and the message: "text.txt" could not be removed Is there a way to fix this error "cleanly" (without any hacks) so that apple will accept this app onto their Mac App Store? EDIT: This is what I am using: [[NSFileManager defaultManager] removeItemAtPath:filePath error:NULL]; Thanks, kevin Error code 4 seems to be NSNoSuchFileError . If the file you

how to get URL Path for directory inside Document directory?

筅森魡賤 提交于 2019-12-01 18:35:29
How can I get url path for a particular directory inside Document Directory. like Document/Art/ My code - (NSURL *)localRoot { if (_localRoot != nil) { return _localRoot; } NSArray * paths = [[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]; _localRoot = [paths objectAtIndex:0]; return _localRoot; } The above code is url path for Documents directory but I need Art document directory path. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0];

Error while checking if a file exists

牧云@^-^@ 提交于 2019-12-01 17:49:34
问题 I'm trying to write to a plist file using writeToFile, before I write I check whether the file exists. This is the code: #import "WindowController.h" @implementation WindowController @synthesize contacts; NSString *filePath; NSFileManager *fileManager; - (IBAction)addContactAction:(id)sender { NSDictionary *dict =[NSDictionary dictionaryWithObjectsAndKeys: [txtFirstName stringValue], @"firstName", [txtLastName stringValue], @"lastName", [txtPhoneNumber stringValue], @"phoneNumber", nil];

Using NSFileManager and createDirectoryAtPath in Swift

微笑、不失礼 提交于 2019-12-01 17:30:57
问题 I'm trying to create a new folder, but I can't figure out how to use createDirectoryAtPath correctly. According to the documentation, this is the correct syntax: NSFileManager.createDirectoryAtPath(_:withIntermediateDirectories:attributes:error:) I tried this: let destinationFolder: String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String let deliverablePath: NSURL = NSURL.fileURLWithPath("\(destinationFolder)/\(arrayOfProjectIDs[index])")!

How do I verify a file's existence in iCloud?

て烟熏妆下的殇ゞ 提交于 2019-12-01 15:01:20
I know that the file exists, because I can download it, but I need to check to see whether it exists. I have tried using [NSFileManager contentsOfDirectoryAtPath:error:] but it gives me null. I don't understand why that is because I can still download the files that I'm looking for. Maybe it's an incorrect URL, but the URL that I'm using is the one that I printed at creation of my UIDocument that I'm looking for. Maybe I'm using the wrong method? EDIT: I have also tried using NSMetadataQuery, and I can get it to give back notifications, but it doesn't ever have results even though I can

Copy / Backup Persistent Store

走远了吗. 提交于 2019-12-01 12:28:09
Normally when I backed up the core data file for my app, I would just copy the .sqlite file to another location while the app was running. But now that journaling (wal) is enabled, this does not work anymore. I cannot see a way for NSPersistentStoreCordinator or NSManagedObjectContext to write a new file. I'm guessing maybe I have 2 methods: Close the persistent store and opening it again with @{@"journal_mode" : @"DELETE"} and then copy the .sqlite file. Add another persistent store and maybe copy from the original ps to the new one ? Any better ideas ? Thank you. Changing the journal mode