Posted By

0xced on 10/31/07


Tagged

reload preference pane prefpane


Versions (?)

Detect already loaded older version of a preference pane


 / Published in: Objective C
 

This detects if a preference pane is loaded over an already loaded older version. If the version mismatches, the reload tool (http://snipplr.com/view/3924/reload-a-preference-pane/) is launched and System Preferences is quitted.

  1. - (id)initWithBundle:(NSBundle *)bundle
  2. {
  3. if ([[self class] version] != 0) {
  4. NSString *reloadPath = [bundle pathForResource:@"reload" ofType:nil];
  5. [NSTask launchedTaskWithLaunchPath:reloadPath arguments:[NSArray arrayWithObjects:[bundle bundleIdentifier],
  6. [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], nil]];
  7. [NSApp terminate:self];
  8. }
  9. [[self class] setVersion:1];
  10.  
  11. if ((self = [super initWithBundle:bundle]) != nil) {
  12. // initializations
  13. }
  14. return self;
  15. }

Report this snippet  

You need to login to post a comment.