The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > Developer > Omni Frameworks
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Proper way of implementing writePreviewsForDocument:error Thread Tools Search this Thread Display Modes
Hi again -

In my custom OUIDocument subclass I override writePreviews with the following implementation:

1) create my images. both landscape and portrait
2) cache them like this:
Code:
[OUIDocumentPreview cachePreviewImages:^(OUIDocumentPreviewCacheImage cacheImage){
        cacheImage(landscapeImage, [OUIDocumentPreview fileURLForPreviewOfFileURL:fileURL date:date withLandscape:YES]);
        cacheImage(portraitImage, [OUIDocumentPreview fileURLForPreviewOfFileURL:fileURL date:date withLandscape:NO]);
    }];
3) actually write out the previous to disk like this:
Code:
    NSData *imageData = UIImageJPEGRepresentation([UIImage imageWithCGImage:landscapeImage], 1.0);
    [imageData writeToURL:[OUIDocumentPreview fileURLForPreviewOfFileURL:fileURL date:date withLandscape:YES] options:0 error:outError];
    
    imageData = UIImageJPEGRepresentation([UIImage imageWithCGImage:portraitImage], 1.0);
    [imageData writeToURL:[OUIDocumentPreview fileURLForPreviewOfFileURL:fileURL date:date withLandscape:NO] options:0 error:outError];
Seems to work but is this the proper way of implementing this method?

Thanks in advance
 
This looks fine at a glance. One note though -- this API will be changing slightly in the next source release (which I started working on preparing today...). The change is pretty minor, but OUIDocumentPreview now does the CGImageRef->JPEG compression and the file I/O on a background queue to reduce the time spent blocking the main thread. This helps reduce stuttering when scrolling in the document picker while previews are being generated.
__________________
CTO, The Omni Group
 
Thanks for the quick reply. Excellent idea about the compression, I was wondering about that myself and arbitrarily set it. Can't wait for your updates.

By the way (If I didn't ask before), do you have a "roadmap" for the framework? The last updates were pretty massive and sort of caught me by surprise. We should all be grateful for this "gift" from Omni, and this probably isn't your main priority, but I'm seriously contemplating releasing a product using your excellent framework. You get my drift...

Thanks again!
 
Our next round of apps will have the grid-based document picker, faster/better preview generation, better use of NSFileCoordinator, better handling of software and external keyboard sizing, some document open/close animation improvements, improved Mail/zip file wrapper handling, better 5.1 compatibility, and probably a bunch of other stuff I'm forgetting.

After that, we're going to resume work on folders and iCloud. A bunch of iCloud work is in place, but not all of it (conflict resolution in particular needs some more work). A small amount of folder UI work is in place. The iCloud stuff depends on either Apple fixing a few bugs in 5.1 or us finding workarounds.

Beyond that... there is a bunch of other stuff we can do, but we'll have to see what customers want most at that point.
__________________
CTO, The Omni Group
 
Thanks Tim!

That's already plenty for me to plan around, so I don't get into refactoring mode too often (smile)

If there's anyway I can help, don't hesitate to ask. I know this isn't exactly open source and I don't see you pulling much in.

Regards and best of luck...
 
Thanks! We've pulled a few patches for the text editor, but I stopped aggressively pulling changes since it seems better to wait for people to send pull requests.

Also, these huge dumps from svn to github -- while better than our old tarball approach -- aren't that helpful for others wanting to help out. We've been toying with the idea of using git internally, but we haven't had bandwidth to tackle that change yet.
__________________
CTO, The Omni Group
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
New task will be forgotten because I'm implementing it the wrong way carlsson Applying OmniFocus 8 2011-10-26 11:59 PM
Another attempt at implementing GTD horizons in Omnifocus sriggs Applying OmniFocus 25 2011-04-28 01:33 AM
Implementing OmniFocus into my daily calendar daniel Applying OmniFocus 6 2010-08-27 12:28 PM
Proper ad blocking hardcoreUFO OmniWeb Feature Requests 15 2009-03-26 12:20 PM


All times are GMT -8. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.