• 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: sandbox method to open my user manual pdf
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sandbox method to open my user manual pdf


  • Subject: Re: sandbox method to open my user manual pdf
  • From: Keith Knauber <email@hidden>
  • Date: Wed, 19 Dec 2012 23:58:11 +0000
  • Thread-topic: sandbox method to open my user manual pdf

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
email@hidden
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                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada



_______________________________________________

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: sandbox method to open my user manual pdf
      • From: Sean McBride <email@hidden>
References: 
 >sandbox method to open my user manual pdf (From: Keith Knauber <email@hidden>)
 >Re: sandbox method to open my user manual pdf (From: Sean McBride <email@hidden>)

  • Prev by Date: Re: NSRulerView as timeline?
  • Next by Date: Re: iOS - needs-shine app pList setting being ignored on devices.
  • Previous by thread: Re: sandbox method to open my user manual pdf
  • Next by thread: Re: sandbox method to open my user manual pdf
  • Index(es):
    • Date
    • Thread