I'm running 10.7.5 on my machine

I think I found a workaround…
First copy the .pdf to my sandbox, then openURL.

> NSString *userManual =  [[NSBundle mainBundle]
> pathForResource:@"User_Manual_v3.6" ofType:@"pdf"];

      NSFileManager *fm = [NSFileManager defaultManager];
      NSString *sandboxPath = [[NSString applicationSupportPath] 
stringByAppendingPathComponent:[path lastPathComponent]];
      if ( ![fm fileExistsAtPath:sandboxPath] )
         [fm copyItemAtPath: userManual toPath: sandboxPath error:nil];
      //- (BOOL)selectFile:(NSString *)fullPath 
inFileViewerRootedAtPath:(NSString *)rootFullpath;
      if ( [fm fileExistsAtPath:sandboxPath] )
         [[NSWorkspace sharedWorkspace] openURL: [NSURL fileURLWithPath: 
sandboxPath]];



@implementation NSString  ( VNSStringPathCategory )
+ ( NSString * ) applicationSupportPath
{
   NSArray *paths = 
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, 
NSUserDomainMask, YES);
   NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] 
:NSTemporaryDirectory();
   if ( basePath )
   {
      basePath = [basePath addComponent: [[NSBundle mainBundle] 
bundleIdentifier]
                           createFolder: YES 
                           resolveAlias: NO ] ;
   }
   return basePath;
}
@end

Keith Knauber
Senior Software Engineer
Production Resource Group
8617 Ambassador Row, Suite 120
Dallas, Texas 75247
214-819-3145 Phone
214-477-3928 Mobile
214-630-5867 Fax
kknau...@prg.com
www.prg.com

On Dec 18, 2012, at 1:50 PM, Sean McBride wrote:

On Tue, 18 Dec 2012 17:53:53 +0000, Keith Knauber said:

> Another simple task made impossibly complex by the sandbox…
> opening User_Manual_v3.6.pdf

That was the case in old version of 10.7... what version are you using?

> NSString *userManual =  [[NSBundle mainBundle]
> pathForResource:@"User_Manual_v3.6" ofType:@"pdf"];
> [[NSWorkspace sharedWorkspace] openFile: userManual]; // sandbox violation

I do it this way:

        NSBundle* bundle = [NSBundle bundleForClass:[self class]];
        NSURL* url = [bundle URLForResource:@"foo" withExtension:@"pdf"];
        BOOL success = [[NSWorkspace sharedWorkspace] openURL:url];

Cheers,

-- 
____________________________________________________________
Sean McBride, B. Eng                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to