We Recommend

Programming in Objective-C Programming in Objective-C
Programming in Objective-C is a concise, carefully written tutorial on the basics of Objective-C and object-oriented programming. The book makes no assumption about prior experience with object-oriented programming languages or with the C language (upon which Objective-C is based). And because of this, both novice and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C.


Ballyhoo


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.