Skip to content

Commit

Permalink
removes dependency to NSBundle
Browse files Browse the repository at this point in the history
  • Loading branch information
HBehrens committed Jul 29, 2012
1 parent 04d1a25 commit 641000b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
4 changes: 1 addition & 3 deletions StartAtLoginController.h
Expand Up @@ -31,9 +31,7 @@
@property (assign, nonatomic, readwrite) BOOL startAtLogin;
@property (assign, nonatomic, readwrite) BOOL enabled;
@property (copy, nonatomic, readwrite) NSString *identifier;
@property (copy, nonatomic, readwrite) NSURL *url;

- (id)initWithBundle:(NSBundle*)bndl;
- (void)setBundle:(NSBundle*)bndl;
-(id)initWithIdentifier:(NSString*)identifier;

@end
31 changes: 12 additions & 19 deletions StartAtLoginController.m
Expand Up @@ -26,12 +26,10 @@
@implementation StartAtLoginController

@synthesize identifier = _identifier;
@synthesize url = _url;

#if !__has_feature(objc_arc)
- (void)dealloc {
self.identifier = nil;
self.url = nil;
[super dealloc];
}
#endif
Expand All @@ -50,26 +48,21 @@ + (BOOL)automaticallyNotifiesObserversForKey:(NSString *)theKey {
return automatic;
}

-(id)initWithBundle:(NSBundle*)bndl
{
self = [super init];
if (self) {
_enabled = NO;
[self setBundle:bndl];

// this method call initializes _enabled to the correct value as a side effect.
[self startAtLogin];
#if !defined(NDEBUG)
NSLog(@"Launcher '%@' %@ configured to start at login",
self.identifier, (_enabled ? @"is" : @"is not"));
#endif
-(id)initWithIdentifier:(NSString*)identifier {
self = [self init];
if(self) {
self.identifier = identifier;
}
return self;
}

- (void)setBundle:(NSBundle*)bndl {
self.identifier = [bndl bundleIdentifier];
self.url = [bndl bundleURL];
-(void)setIdentifier:(NSString *)identifier {
_identifier = identifier;
[self startAtLogin];
#if !defined(NDEBUG)
NSLog(@"Launcher '%@' %@ configured to start at login",
self.identifier, (_enabled ? @"is" : @"is not"));
#endif
}

- (BOOL)startAtLogin {
Expand Down Expand Up @@ -101,7 +94,7 @@ - (BOOL)startAtLogin {
}

- (void)setStartAtLogin:(BOOL)flag {
if (!_identifier||!_url)
if (!_identifier)
return;

[self willChangeValueForKey:@"startAtLogin"];
Expand Down

0 comments on commit 641000b

Please sign in to comment.