nsfilemanager

NSFilemanager uploads new file, but UIWebView shows cached version

耗尽温柔 提交于 2020-01-06 15:41:17
问题 An app I'm building needs to periodically check a known location for an updated file. It happens to be a PDF. If x amount of time has passed, the app needs to upload a new copy of the file. The following code snippet works. It downloads the file. But the app displays a cached version of the PDF instead of the new one. I confirmed this by looking in the app bundle. After this code runs, there is definitely a new file in the Documents directory. But in the bundle's tmp/DiskImageCache-[random

NSFilemanager uploads new file, but UIWebView shows cached version

旧巷老猫 提交于 2020-01-06 15:41:09
问题 An app I'm building needs to periodically check a known location for an updated file. It happens to be a PDF. If x amount of time has passed, the app needs to upload a new copy of the file. The following code snippet works. It downloads the file. But the app displays a cached version of the PDF instead of the new one. I confirmed this by looking in the app bundle. After this code runs, there is definitely a new file in the Documents directory. But in the bundle's tmp/DiskImageCache-[random

Print all filenames in a folder in iOS application

爷,独闯天下 提交于 2020-01-06 06:57:32
问题 I have a folder with 4 subfolders in my iOS application with each of these containing about 20 files each. I would like to be able to iterate through each folder and print out the filenames. I am not sure how to go about doing this. Here is what I have tried: let docsPath = NSBundle.mainBundle().resourcePath! + "/Samples"; let fileManager = NSFileManager.defaultManager() var error: NSError? let docsArray = fileManager.contentsOfDirectoryAtPath(docsPath, error:&error) println(docsArray) This

Why a Database hasn't created?

不羁岁月 提交于 2020-01-05 09:06:18
问题 I've tried to create a Database using sqlite3.0 in my app, but the database hasn't created. Here is my code: // Getting the documents directory dirPaths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES); docsDir = dirPaths[0]; // Built the path to the database file _databasePath = [[NSString alloc] initWithString: [docsDir stringByAppendingPathComponent: @"contacts1.db"]];//here the database name is contacts1.db. NSFileManager *filemgr = [NSFileManager

App hangs deleting iCloud Document when following  guideline using NSFileCoordinator and DispatchQueue

♀尐吖头ヾ 提交于 2020-01-05 08:52:46
问题 I have a todo list app that stores document in iCloud as UIDocument object. The following function in the table view controller is created to delete a todo list item both locally and remotely in iCloud but hang the app when executed it via swipe to delete gesture on the table view cell: fileprivate func deleteNote(at indexPath: IndexPath) { let noteDocument = self.noteDocuments[indexPath.row] let fileCoordinator = NSFileCoordinator(filePresenter: nil) fileCoordinator.coordinate(writingItemAt:

App hangs deleting iCloud Document when following  guideline using NSFileCoordinator and DispatchQueue

谁都会走 提交于 2020-01-05 08:51:41
问题 I have a todo list app that stores document in iCloud as UIDocument object. The following function in the table view controller is created to delete a todo list item both locally and remotely in iCloud but hang the app when executed it via swipe to delete gesture on the table view cell: fileprivate func deleteNote(at indexPath: IndexPath) { let noteDocument = self.noteDocuments[indexPath.row] let fileCoordinator = NSFileCoordinator(filePresenter: nil) fileCoordinator.coordinate(writingItemAt:

How do I properly manage iCloud files via NSFileManager?

孤者浪人 提交于 2020-01-05 05:53:27
问题 I am attempting to add iCloud synching to my iOS/Mac app by using the iCloud methods on NSFileManager (no documents or file coordinators). The app needs to synch audio files across the various instances; create, delete and metadata changes. It isn't a collaboration style app, so I am not very worried about conflicts, etc. I have something basic working, but have run into some basic questions that I can't seem to find definitive answers to. When using iCloud, there are two local directories

Replace a file using the NSSavePanel in a sandboxed application

我怕爱的太早我们不能终老 提交于 2020-01-04 06:11:42
问题 I create a NSSavePanel using this code: NSSavePanel *savePanel = [NSSavePanel savePanel]; savePanel.delegate = self; savePanel.directoryURL = ...; savePanel.nameFieldStringValue = ...; [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger returnCode) { if (returnCode == NSFileHandlingPanelOKButton) { // the completion handler } }]; If in the save panel the user select an already existing file, appears the alert box "“XXX” already exists. Do you want to replace it?". If

Replace a file using the NSSavePanel in a sandboxed application

眉间皱痕 提交于 2020-01-04 06:11:09
问题 I create a NSSavePanel using this code: NSSavePanel *savePanel = [NSSavePanel savePanel]; savePanel.delegate = self; savePanel.directoryURL = ...; savePanel.nameFieldStringValue = ...; [savePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger returnCode) { if (returnCode == NSFileHandlingPanelOKButton) { // the completion handler } }]; If in the save panel the user select an already existing file, appears the alert box "“XXX” already exists. Do you want to replace it?". If

Load file in Today extension when device is locked

佐手、 提交于 2020-01-04 06:07:20
问题 In my today extension with my device unlocked, this line of code works as expected, returning the data from the image path: let imageData = NSData(contentsOfFile: path) However when my device is locked with a passcode, it returns nil. Is there any way to access images in the file system when the device is locked? I can access UserDefaults just fine, but not files in the directory for my shared group. Here is how I am creating the path, calling imagePath , which is correctly populated with the