• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Best 'Cocoa' File Preview
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best 'Cocoa' File Preview


  • Subject: Re: Best 'Cocoa' File Preview
  • From: David Blanton <email@hidden>
  • Date: Sun, 12 Jul 2009 16:58:37 -0600

I am traveling down the QuickLook path ...

I have followed all directions but my code is not being called by qlmange as evidenced here:

7/12/09 4:46:08 PM qlmanage[855] [QL] Thumbnailing /users/davidblanton/ Aibnb18.pes. Content type UTI: dyn.ah62d4rv4ge81a3px. Generator used: None
7/12/09 4:46:08 PM qlmanage[855] [QL] Thumbnailing for /users/ davidblanton/Aibnb18.pes done (No image created).



Is there some known secret sauce not divulged in the docs?





On Jul 12, 2009, at 12:24 AM, Graham Cox wrote:


On 12/07/2009, at 1:02 PM, David Blanton wrote:

What is the preferred method of showing a file preview (my unique content) in an NSOpenPanel ?

The Accessory View looks 'hooky' to use , I want the preview in the next browser column.



If you can image your content to a JPEG and/or PDF, it's very easy to add these as Quicklook thumbnails and previews to a document package. That avoids the need to write a QL plug-in for your format, and the Open panel and Finder and QL preview in the Finder will display these directly.

You need to use particular names for these preview images - it's given in the docs somewhere. Here's the code I use to add them in my app (subclass of NSDocument):



- (NSFileWrapper*) fileWrapperOfType:(NSString*) typeName error: (NSError**) outError
{
NSData* mainContent = [self dataOfType:typeName error:outError];


if( mainContent == nil )
{
if( outError )
*outError = [NSError errorWithDomain:kOrteliusErrorDomain code:kOrteliusNoDataErrorCode userInfo:nil];
return nil;
}


NSFileWrapper* fw = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:nil];
[fw addRegularFileWithContents:mainContent preferredFilename:kOrteliusFilePackageMainContentFile];

// add "Quick Look" preview folder:

NSFileWrapper* qlFolder = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:nil];
[qlFolder setPreferredFilename:@"QuickLook"];
[fw addFileWrapper:qlFolder];
[qlFolder release];

// add preview and thumbnail

NSData* preview = [[self drawing] thumbnailData]; // JPEG data

if( preview )
[qlFolder addRegularFileWithContents:preview preferredFilename:@"Thumbnail.jpg"];

preview = [[self drawing] pdf]; // PDF data
if( preview )
[qlFolder addRegularFileWithContents:preview preferredFilename:@"Preview.pdf"];

return [fw autorelease];
}



--Graham







_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Best 'Cocoa' File Preview
      • From: Julien Jalon <email@hidden>
References: 
 >Best 'Cocoa' File Preview (From: David Blanton <email@hidden>)
 >Re: Best 'Cocoa' File Preview (From: Graham Cox <email@hidden>)

  • Prev by Date: CAKeyframeAnimation problem
  • Next by Date: Re: Best 'Cocoa' File Preview
  • Previous by thread: Re: Best 'Cocoa' File Preview
  • Next by thread: Re: Best 'Cocoa' File Preview
  • Index(es):
    • Date
    • Thread