Re: Get the package's NSBundle from a plugin
site_archiver@lists.apple.com Delivered-To: installer-dev@lists.apple.com User-agent: Thunderbird 1.5.0.10 (Macintosh/20070221) . . . I've also tried using mpkgBundle = [ NSBundle bundleForClass:[ self Class ] ]; as suggested but self does not respond to the Class message in that context. Thanks, Mike Hi Mike, - Luke On Apr 13, 2007, at 5:36 AM, Stéphane Sudre wrote: Why wouldn't it work (if you replace Class with class)? On Apr 13, 2007, at 5:02 AM, Mike wrote: Thanks, Mike _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/luke%40apple.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/site_archiver%40lists.a... Our installer needs to be able to delete itself at the end of the installations process - based on a checkbox setting the user sets in one of the panes. So I wrote a custom plugin to do this based on whether or not the user checks the box at the end of the install. Since the installer is running with our .mpkg, and since we require restart after install, the easiest way for me to do this is to just have my Delete plugin move the entire .mpkg directory to /tmp. That way when the user clicks the "Restart" button and the system restarts, the entire .mpkg will be blown away automatically because it's in /tmp. The problem is, all attempts to get the .mpkg's bundle have failed - I have only been able to get the plugin's bundle itself. Here is the code from the plugin currently: - (BOOL)shouldExitPane:(InstallerSectionDirection)dir { BOOL result = NO; int checkState = 0; char ourDestCPath[ kTempDeletePathLength ]; NSBundle *mpkgBundle = nil; NSBundle *ourBundle = nil; NSString *ourBundlePath = nil; NSString *ourDestPath = nil; InstallerSection *ourSection = nil; NSFileManager *defaultFileManager = nil; NSDictionary *packageAttribs = nil; if( ( dir == InstallerDirectionForward ) ) { // If "delete" checkbox is on then move the installer to /tmp... checkState = [ uiDeleteCheck intValue ]; if( checkState == 1 ) { ////////////////////////////////////////////////////// // Move the installer to /private/tmp so that it gets // deleted on the next reboot. ////////////////////////////////////////////////////// ourSection = [ self section ]; if( ourSection ) { ourBundle = [ ourSection bundle ]; if( ourBundle ) { // Trick to get the plugin's .mpkg Bundle... mpkgBundle = [ NSBundle bundleForClass:[ ourBundle Class ] ]; ourBundlePath = [ mpkgBundle bundlePath ]; if( ourBundlePath ) { // Get default system NSFileManager... defaultFileManager = [ NSFileManager defaultManager ]; if( defaultFileManager ) { // Move entire .mpkg to /tmp memset( ourDestCPath, 0, kTempDeletePathLength ); strcpy( ourDestCPath, "/private/tmp/Spector Installer" ); ourDestPath = [ [ NSString alloc ] initWithCString:ourDestCPath ]; if( ourDestPath ) { result = [ defaultFileManager movePath:ourBundlePath toPath:ourDestPath handler:nil ]; Am I supposed to substitute my plugin's class in place of Class in the above statement? Luke Bellandi wrote: What exactly are you trying to do here that you need the package's bundle for? You probably have at least one subclass of the Installer Plugins classes. If you run this method on an instance of this subclass, you will get the NSBundle of the plugin. Then you would just have to build the path of the metapackage "bundle" from the path of the plugin bundle (+[NSBundle bundleWithPath:]). That would be a neat trick but in this case it won't work because self is an InstallerPane which is a member of an InstallerSection which is an NSView in the class object. Peter Bierman wrote: At 6:01 PM -0700 4/12/07, Mike wrote: Is there an easy way to get the NSBundle of the .mpkg that contains a plugin from the plugin's code? I see the InstallerSection class has a -bundle method but it appears to return the plugin's bundle, not the bundle of the .mpkg itself. This also doesn't seem to be mentioned in Software Delivery Guide. A useful NSBundle trick for plugins everywhere: [NSBundle bundleForClass:[self Class]] This should find you the bundle that whatever class you're in came from. -pmb _______________________________________________ Do not post admin requests to the list. They will be ignored. Installer-dev mailing list (Installer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/installer-dev/ssudre2%40wanadoo.fr This email sent to ssudre2@wanadoo.fr --------------------------------------------------------------------------------------- Orange vous informe que cet e-mail a ete controle par l'anti-virus mail. Aucun virus connu a ce jour par nos services n'a ete detecte. This email sent to luke@apple.com This email sent to site_archiver@lists.apple.com
participants (1)
-
Mike