From ec6bc3c1a76f6f4da070aab5b98ca3ef35eddb17 Mon Sep 17 00:00:00 2001 From: Vadim Shpakovski Date: Mon, 9 Apr 2012 16:01:40 +0300 Subject: [PATCH] Fixes accessors for ARC. --- Popup/ApplicationDelegate.h | 7 ++----- Popup/ApplicationDelegate.m | 15 ++++++--------- Popup/MenubarController.h | 2 +- Popup/StatusItemView.m | 3 +-- 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Popup/ApplicationDelegate.h b/Popup/ApplicationDelegate.h index af1d476..cb51ec5 100644 --- a/Popup/ApplicationDelegate.h +++ b/Popup/ApplicationDelegate.h @@ -1,13 +1,10 @@ #import "MenubarController.h" #import "PanelController.h" -@interface ApplicationDelegate : NSObject { - MenubarController *_menubarController; - PanelController *_panelController; -} +@interface ApplicationDelegate : NSObject @property (nonatomic, strong) MenubarController *menubarController; -@property (nonatomic, unsafe_unretained, readonly) PanelController *panelController; +@property (nonatomic, strong, readonly) PanelController *panelController; - (IBAction)togglePanel:(id)sender; diff --git a/Popup/ApplicationDelegate.m b/Popup/ApplicationDelegate.m index 3c30e3b..d58540c 100644 --- a/Popup/ApplicationDelegate.m +++ b/Popup/ApplicationDelegate.m @@ -1,9 +1,8 @@ #import "ApplicationDelegate.h" -void *kContextActivePanel = &kContextActivePanel; - @implementation ApplicationDelegate +@synthesize panelController = _panelController; @synthesize menubarController = _menubarController; #pragma mark - @@ -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]; } } @@ -39,7 +38,6 @@ - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sende { // Explicitly remove the icon from the menu bar self.menubarController = nil; - return NSTerminateNow; } @@ -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]; } diff --git a/Popup/MenubarController.h b/Popup/MenubarController.h index 9fbdd2f..22c912d 100644 --- a/Popup/MenubarController.h +++ b/Popup/MenubarController.h @@ -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 diff --git a/Popup/StatusItemView.m b/Popup/StatusItemView.m index 75a8129..f5571d0 100644 --- a/Popup/StatusItemView.m +++ b/Popup/StatusItemView.m @@ -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; }