-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could you provide a README and/or examples for usage? #1
Comments
Sorry, I haven't had a chance to do it yet. Been busy with other projects. Essentially you want to subclass LSDocument instead of UIDocument. In the loadFromContents and contentsFromType you basically want to use LSFileWrapper as you would an NSFileWrapper. If contents is nil from loadFromContents you want to create a directory wrapper. You can do this with -initDirectory. You can create files with -initFile and add them with -addFileWrapper or -setFileWrapper - the difference between the two being that add will suffix a filename with a 2, 3, 4, etc... if the file exists already and return the final filename - set will overwrite an existing one. -addContent and -setContent work the same way, but create the file wrapper for you. The key differences are:
The cache is mostly for small files, like html, plist, etc... If you want to load images, I would do it with methods like [UIImage imageWithContentsOfFile]. You'll never have to call - writeUpdateToURL on the LSFileWrapper, unless you're using it outside LSDocument. You always want to call the methods you normally would on UIDocument. There is a "savePathFirst" method in LSDocument that allows you to save a file / directory first before everything else. You use this in cases where you want to save thumbnails to load in something like a UIWebView and save larger files later. It gives you two blocks - one after the initial files are saved, and one after everything has been saved. Another method that's useful to use is -fileWrapperWithPath. It allows you to provide a relative path inside a directory. So you can literally do something like "path/to/foo.html" and it will drill down into it to give you the file wrapper for that file. There is a -fileWrapperWithPath:create:isDirectory that will allow you to create one if it doesn't exist. I typically will use that in combination with -updateContents. Feel free to write a README file and send me a pull request if you want. |
I believe this code is exactly what I'm needing. I've got annoying memory issues with a UIDocument that contains multiple photos/videos that I'm trying to fix. However I'm not certain how to implement this with my current codebase. If you could provide a small sample xcode project, I wouldn't mind writing some documentation and submit it as a pull request once I figure it all out.
The text was updated successfully, but these errors were encountered: