Detect already loaded older version of a preference pane


/ Published in: Objective C
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.