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 Today's Posts

 
Proper way of implementing writePreviewsForDocument:error Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
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
 
 




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 05:58 AM.


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