#import "HMBookmarkManager.h"
#import "HMBookmarkListViewController.h"
+static void *WebViewContext = &WebViewContext;
@interface HMExternalBrowserWindowController () <HMBookmarkListViewControllerDelegate, NSAnimationDelegate, WebFrameLoadDelegate>
[self.webView addObserver:self
forKeyPath:@"canGoBack"
options:0
- context:(__bridge void *)(self.webView)];
+ context:WebViewContext];
[self.webView addObserver:self
forKeyPath:@"canGoForward"
options:0
- context:(__bridge void *)(self.webView)];
+ context:WebViewContext];
HMAppDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
[self.webView setApplicationNameForUserAgent:appDelegate.appNameForUserAgent];
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- id contextObject = (__bridge id)(context);
- if(self.webView == contextObject) {
+ if(context == WebViewContext) {
if([keyPath isEqualToString:@"canGoBack"]) {
[self.goSegment setEnabled:self.webView.canGoBack forSegment:0];
}
#import "HMKCDeck+Extension.h"
#import "HMKCShipObject+Extensions.h"
+
+
+static void *DeckContext = &DeckContext;
+static void *ShipContext = &ShipContext;
+
@interface HMFleet ()
@property (strong) NSNumber *fleetNumber;
@property (strong) NSObjectController *deckController;
[_deckController addObserver:self
forKeyPath:key
options:0
- context:(__bridge void * _Nullable)(_deck)];
+ context:DeckContext];
}
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
{
- id obj = (__bridge id)(context);
- if(obj == _deck) {
+ if(context == DeckContext) {
for(HMKCShipObject *ship in _ships) {
for(NSString *key in self.shipObserveKeys) {
[ship addObserver:self
forKeyPath:key
options:0
- context:(__bridge void * _Nullable)(_ships)];
+ context:ShipContext];
}
}
return;
}
- if(obj == _ships) {
+ if(context == ShipContext) {
if([keyPath isEqualToString:@"sakuteki_0"]) {
[self willChangeValueForKey:@"totalSakuteki"];
[self didChangeValueForKey:@"totalSakuteki"];
#import "HMKCShipObject+Extensions.h"
+
+static void *ShipStatusContext = &ShipStatusContext;
+
+
@interface HMSuppliesView ()
@property (nonatomic, strong) HMSuppliesCell *suppliesCell;
@end
[self.suppliesCell.shipStatus addObserver:self
forKeyPath:@"fuel"
options:NSKeyValueObservingOptionNew
- context:(__bridge void *)(self.suppliesCell.shipStatus)];
+ context:ShipStatusContext];
[self.suppliesCell.shipStatus addObserver:self
forKeyPath:@"maxFuel"
options:NSKeyValueObservingOptionNew
- context:(__bridge void *)(self.suppliesCell.shipStatus)];
+ context:ShipStatusContext];
[self.suppliesCell.shipStatus addObserver:self
forKeyPath:@"bull"
options:NSKeyValueObservingOptionNew
- context:(__bridge void *)(self.suppliesCell.shipStatus)];
+ context:ShipStatusContext];
[self.suppliesCell.shipStatus addObserver:self
forKeyPath:@"maxBull"
options:NSKeyValueObservingOptionNew
- context:(__bridge void *)(self.suppliesCell.shipStatus)];
+ context:ShipStatusContext];
[self setNeedsDisplay];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
- HMKCShipObject *status = (__bridge HMKCShipObject *)(context);
-
- if(status == self.suppliesCell.shipStatus) {
+ if(context ==ShipStatusContext) {
[self setNeedsDisplay];
return;
}