Skip to content
This repository has been archived by the owner on Mar 5, 2023. It is now read-only.

Commit

Permalink
Fixes accessors for ARC.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Shpakovski committed Apr 9, 2012
1 parent b256404 commit ec6bc3c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
7 changes: 2 additions & 5 deletions Popup/ApplicationDelegate.h
@@ -1,13 +1,10 @@
#import "MenubarController.h"
#import "PanelController.h"

@interface ApplicationDelegate : NSObject <NSApplicationDelegate, PanelControllerDelegate> {
MenubarController *_menubarController;
PanelController *_panelController;
}
@interface ApplicationDelegate : NSObject <NSApplicationDelegate, PanelControllerDelegate>

@property (nonatomic, strong) MenubarController *menubarController;
@property (nonatomic, unsafe_unretained, readonly) PanelController *panelController;
@property (nonatomic, strong, readonly) PanelController *panelController;

- (IBAction)togglePanel:(id)sender;

Expand Down
15 changes: 6 additions & 9 deletions Popup/ApplicationDelegate.m
@@ -1,9 +1,8 @@
#import "ApplicationDelegate.h"

void *kContextActivePanel = &kContextActivePanel;

@implementation ApplicationDelegate

@synthesize panelController = _panelController;
@synthesize menubarController = _menubarController;

#pragma mark -
Expand All @@ -15,14 +14,14 @@ - (void)dealloc

#pragma mark -

void *kContextActivePanel = &kContextActivePanel;

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (context == kContextActivePanel)
{
if (context == kContextActivePanel) {
self.menubarController.hasActiveIcon = self.panelController.hasActivePanel;
}
else
{
else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
Expand All @@ -39,7 +38,6 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende
{
// Explicitly remove the icon from the menu bar
self.menubarController = nil;

return NSTerminateNow;
}

Expand All @@ -55,8 +53,7 @@ - (IBAction)togglePanel:(id)sender

- (PanelController *)panelController
{
if (_panelController == nil)
{
if (_panelController == nil) {
_panelController = [[PanelController alloc] initWithDelegate:self];
[_panelController addObserver:self forKeyPath:@"hasActivePanel" options:0 context:kContextActivePanel];
}
Expand Down
2 changes: 1 addition & 1 deletion Popup/MenubarController.h
Expand Up @@ -10,7 +10,7 @@
}

@property (nonatomic) BOOL hasActiveIcon;
@property (nonatomic, unsafe_unretained, readonly) NSStatusItem *statusItem;
@property (nonatomic, strong, readonly) NSStatusItem *statusItem;
@property (nonatomic, strong, readonly) StatusItemView *statusItemView;

@end
3 changes: 1 addition & 2 deletions Popup/StatusItemView.m
Expand Up @@ -18,8 +18,7 @@ - (id)initWithStatusItem:(NSStatusItem *)statusItem
NSRect itemRect = NSMakeRect(0.0, 0.0, itemWidth, itemHeight);
self = [super initWithFrame:itemRect];

if (self != nil)
{
if (self != nil) {
_statusItem = statusItem;
_statusItem.view = self;
}
Expand Down

0 comments on commit ec6bc3c

Please sign in to comment.