nsfilewrapper

Sharing a plist file using iCloud

眉间皱痕 提交于 2021-02-06 09:12:59
问题 I have a relativley simple app which persists data to a plist file located in the documents folder. The data loads into a UITableView at startup. The user can then edit, delete or add records and any changes get saved back to the plist file. Now I would like to share this data (the plist file) across devices using iCloud. I have looked at the documentation and my understanding is that I need to create a UIDocument to "manage" the plist file. I have looked at several iCloud tutorials however

Sharing a plist file using iCloud

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-06 09:12:34
问题 I have a relativley simple app which persists data to a plist file located in the documents folder. The data loads into a UITableView at startup. The user can then edit, delete or add records and any changes get saved back to the plist file. Now I would like to share this data (the plist file) across devices using iCloud. I have looked at the documentation and my understanding is that I need to create a UIDocument to "manage" the plist file. I have looked at several iCloud tutorials however

Does NSFileWrapper load everything into memory?

泄露秘密 提交于 2019-12-29 07:07:29
问题 Lets say I have an NSFileWrapper directory. This directory is made up of several levels of directories and files. Some of the files are large. Are all these files loaded into memory, or are they lazily loaded? If they are loaded into memory, are there any alternatives to NSFileWrapper with similar functionality that won't load files into memory? Something I can hook into UIDocument ? This is for a document based application, which uses UIDocument 's that are synced with iCloud. A document can

Recipe for making Cocoa NSDocument packages play well with svn?

本秂侑毒 提交于 2019-12-22 01:13:14
问题 I have a tool that writes package-style documents. It's implemented using NSDocument and overrides the following NSDocument methods: - (NSFileWrapper *)fileWrapperOfType:(NSString *)typeName error:(NSError **)outError; - (BOOL)readFromFileWrapper:(NSFileWrapper *)fileWrapper ofType:(NSString *)typeName error:(NSError **)outError; This is all lovely, except when I save a document that's under version control. (The .svn directories aren't preserved, etc.) Is there a good recipe somewhere for

UIDocument & NSFileWrapper - large files taking a long time to save, despite incremental changes

不羁岁月 提交于 2019-12-21 10:14:35
问题 I have a UIDocument based app that uses NSFileWrapper s to store data. The 'master' file wrapper contains many additional directory file wrappers, each of which represents a different page of the document. When saving a large document for which only a small proportion of one page has been modified, UIDocument spends a LONG time in the background writing the changes (in writeContents:andAttributes:safelyToURL:forSaveOperation:error: ). Surely it should only be writing out this one small change

Check if two files are the same in Cocoa

旧时模样 提交于 2019-12-19 07:53:46
问题 How do you efficiently check if two files are the same (have the same data) in Cocoa? Context: I'm writing a program that receives a file as input (input file) and copies it into a directory. If the directory already contains a file with the same name (namesake file) then the input file should be copied with a new name only if the namesake file is different. 回答1: you can use -[NSFileManager contentsEqualAtPath:andPath:] . From the Docs: If path1 and path2 are directories, the contents are the

How to update an NSFileWrapper?

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:16:32
问题 I have an NSFileWrapper with some content. I want to save it ( writeToURL...: ), add new content to it and save it again . I would like to avoid writing again and again the same files. So, if I understood clearly, it means the option NSFileWrapperWritingAtomic is not for me. Especially as I save the file wrapper in the method - (BOOL)writeAdditionalContent:(id)content toURL:(NSURL *)absoluteURL originalContentsURL:(NSURL *)absoluteOriginalContentsURL error:(NSError *__autoreleasing *)error

iOS app with core data, photos & iCloud

青春壹個敷衍的年華 提交于 2019-12-10 17:03:35
问题 I'm developing an app that uses core data (with UIManagedDocument) for storing user-generated data that I would like to sync with iCloud. I also would like to sync photos that the user takes with the camera within the app. I read that it's not a good idea to store the actual photos within core data; rather it's better to store the photos in the file system and put the fileURL in core data. Using this method, what is the recommended approach when using UIDocument to store the photos in the

NSMetadataQuery does not find NSFileWrapper folder bundles, only files (but they're there)

时光怂恿深爱的人放手 提交于 2019-12-10 11:33:02
问题 I have a strange problem which I can't seem to solve on my own. Any help or thought is appreciated. The problem: NSMetadataQuery finds normal files (like test.txt) but no filewrapper bundle (myWrapperDocument.pro) However, NSFileManager finds all files in my ubiquity container - so the files are there, but NSMetadataQuery doesn't find them! The facts: UIDocument based app using NSFileWrappers Shared Ubiquity Container (for iOS and Desktop app) Works perfect on Mac OS Works perfect on my iPad

Get path for NSFileWrapper

你。 提交于 2019-12-10 02:36:51
问题 Given an NSFileWrapper object (for a file or directory), is there any way to get the full path for the location of the actual file on the disk? [fileWrapper filename] only returns the file name, not the path, so it isn't what I'm looking for. 回答1: No, there's no way to get the full path from NSFileWrapper . 回答2: If you're using NSDocument you can get the path of regular-file file wrappers with a little hack. First create a NSFileWrapper subclass and overload the regular-file methods that