Skip to content
Browse files

Moved the NSNotification name constants to constant classes with clas…

…s methods.
  • Loading branch information...
1 parent 31efefc commit 0474a8ce1fdb1d9f344d1cc78d951d0638606d1b Seth Landsman committed Dec 24, 2011
View
24 GraphPaperFramework.xcodeproj/project.pbxproj
@@ -34,8 +34,10 @@
5D36F9A01494304B0060D9CB /* GraphPaperFramework.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5D07D370143A7107004BC2A1 /* GraphPaperFramework.framework */; };
5D36F9A1149430770060D9CB /* TwoKeyDictionaryFramework.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 5D07D3BB143A7141004BC2A1 /* TwoKeyDictionaryFramework.framework */; };
5D9EB65614A5454B007ED66A /* ClickSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D9EB65414A5454B007ED66A /* ClickSource.h */; };
- 5D9EB65714A5454B007ED66A /* ClickSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9EB65514A5454B007ED66A /* ClickSource.m */; };
- 5D9EB65A14A54562007ED66A /* CellSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9EB65914A54562007ED66A /* CellSource.m */; };
+ 5D9EB66114A6022A007ED66A /* CellSourceConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D9EB65F14A6022A007ED66A /* CellSourceConstants.h */; };
+ 5D9EB66214A6022A007ED66A /* CellSourceConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9EB66014A6022A007ED66A /* CellSourceConstants.m */; };
+ 5D9EB66514A60796007ED66A /* ClickSourceConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D9EB66314A60796007ED66A /* ClickSourceConstants.h */; };
+ 5D9EB66614A60796007ED66A /* ClickSourceConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D9EB66414A60796007ED66A /* ClickSourceConstants.m */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -115,8 +117,10 @@
5D36F97E149424040060D9CB /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
5D36F981149424040060D9CB /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
5D9EB65414A5454B007ED66A /* ClickSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClickSource.h; sourceTree = "<group>"; };
- 5D9EB65514A5454B007ED66A /* ClickSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClickSource.m; sourceTree = "<group>"; };
- 5D9EB65914A54562007ED66A /* CellSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CellSource.m; sourceTree = "<group>"; };
+ 5D9EB65F14A6022A007ED66A /* CellSourceConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CellSourceConstants.h; sourceTree = "<group>"; };
+ 5D9EB66014A6022A007ED66A /* CellSourceConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CellSourceConstants.m; sourceTree = "<group>"; };
+ 5D9EB66314A60796007ED66A /* ClickSourceConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClickSourceConstants.h; sourceTree = "<group>"; };
+ 5D9EB66414A60796007ED66A /* ClickSourceConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClickSourceConstants.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -201,10 +205,12 @@
5D07D3A6143A7123004BC2A1 /* GraphPaperView.h */,
5D07D3A7143A7123004BC2A1 /* GraphPaperView.m */,
5D07D3A8143A7123004BC2A1 /* CellSource.h */,
- 5D9EB65914A54562007ED66A /* CellSource.m */,
5D9EB65414A5454B007ED66A /* ClickSource.h */,
- 5D9EB65514A5454B007ED66A /* ClickSource.m */,
+ 5D9EB66314A60796007ED66A /* ClickSourceConstants.h */,
+ 5D9EB66414A60796007ED66A /* ClickSourceConstants.m */,
5D07D3A9143A7123004BC2A1 /* GraphPaperCellController.h */,
+ 5D9EB65F14A6022A007ED66A /* CellSourceConstants.h */,
+ 5D9EB66014A6022A007ED66A /* CellSourceConstants.m */,
5D07D3AA143A7123004BC2A1 /* GraphPaperCellController.m */,
5D07D380143A7107004BC2A1 /* GraphPaperFramework.h */,
5D07D381143A7107004BC2A1 /* GraphPaperFramework.m */,
@@ -277,6 +283,8 @@
5D07D3B2143A7123004BC2A1 /* CellSource.h in Headers */,
5D07D3B3143A7123004BC2A1 /* GraphPaperCellController.h in Headers */,
5D9EB65614A5454B007ED66A /* ClickSource.h in Headers */,
+ 5D9EB66114A6022A007ED66A /* CellSourceConstants.h in Headers */,
+ 5D9EB66514A60796007ED66A /* ClickSourceConstants.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -422,8 +430,8 @@
5D07D3AF143A7123004BC2A1 /* GraphPaperCell.m in Sources */,
5D07D3B1143A7123004BC2A1 /* GraphPaperView.m in Sources */,
5D07D3B4143A7123004BC2A1 /* GraphPaperCellController.m in Sources */,
- 5D9EB65714A5454B007ED66A /* ClickSource.m in Sources */,
- 5D9EB65A14A54562007ED66A /* CellSource.m in Sources */,
+ 5D9EB66214A6022A007ED66A /* CellSourceConstants.m in Sources */,
+ 5D9EB66614A60796007ED66A /* ClickSourceConstants.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
4 GraphPaperFramework/CellSource.h
@@ -11,9 +11,7 @@
#import <Foundation/Foundation.h>
-@interface CellSource : NSObject
-
-extern NSString * const kGPVCellsDidUpdate;
+@protocol CellSource <NSObject>
-(NSSet *)cells;
View
20 GraphPaperFramework/CellSource.m
@@ -1,20 +0,0 @@
-//
-// CellSource.m
-// GraphPaperFramework
-//
-// Created by Seth Landsman on 12/23/11.
-// Copyright (c) 2011 HomeForDerangedScientists. All rights reserved.
-//
-
-#import "CellSource.h"
-
-@implementation CellSource
-
-NSString * const kGPVCellsDidUpdate = @"kGPVCellsDidUpdate";
-
--(NSSet *)cells
-{
- return nil;
-}
-
-@end
View
15 GraphPaperFramework/CellSourceConstants.h
@@ -0,0 +1,15 @@
+//
+// CellSourceConstants.h
+// GraphPaperFramework
+//
+// Created by Seth Landsman on 12/24/11.
+// Copyright (c) 2011 HomeForDerangedScientists. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface CellSourceConstants : NSObject
+
++(NSString *)kGPVCellsDidUpdate;
+
+@end
View
20 GraphPaperFramework/CellSourceConstants.m
@@ -0,0 +1,20 @@
+//
+// CellSourceConstants.m
+// GraphPaperFramework
+//
+// Created by Seth Landsman on 12/24/11.
+// Copyright (c) 2011 HomeForDerangedScientists. All rights reserved.
+//
+
+#import "CellSourceConstants.h"
+
+@implementation CellSourceConstants
+
+static NSString *kGPVCellsDidUpdate_value = @"kGPVCellsDidUpdate";
+
++(NSString *)kGPVCellsDidUpdate
+{
+ return kGPVCellsDidUpdate_value;
+}
+
+@end
View
4 GraphPaperFramework/ClickSource.h
@@ -8,8 +8,6 @@
#import <Foundation/Foundation.h>
-@interface ClickSource : NSView
-
-extern NSString * const kGPVClickDidOccur;
+@protocol ClickSource
@end
View
15 GraphPaperFramework/ClickSource.m
@@ -1,15 +0,0 @@
-//
-// ClickSource.m
-// GraphPaperFramework
-//
-// Created by Seth Landsman on 12/23/11.
-// Copyright (c) 2011 HomeForDerangedScientists. All rights reserved.
-//
-
-#import "ClickSource.h"
-
-@implementation ClickSource
-
-NSString * const kGPVClickDidOccur = @"kGPVClickDidOccur";
-
-@end
View
15 GraphPaperFramework/ClickSourceConstants.h
@@ -0,0 +1,15 @@
+//
+// ClickSourceConstants.h
+// GraphPaperFramework
+//
+// Created by Seth Landsman on 12/24/11.
+// Copyright (c) 2011 HomeForDerangedScientists. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface ClickSourceConstants : NSObject
+
++(NSString *)kGPVClickDidOccur;
+
+@end
View
20 GraphPaperFramework/ClickSourceConstants.m
@@ -0,0 +1,20 @@
+//
+// ClickSourceConstants.m
+// GraphPaperFramework
+//
+// Created by Seth Landsman on 12/24/11.
+// Copyright (c) 2011 HomeForDerangedScientists. All rights reserved.
+//
+
+#import "ClickSourceConstants.h"
+
+@implementation ClickSourceConstants
+
+static NSString *kGPVClickDidOccur_value = @"kGPVClickDidOccur";
+
++(NSString *)kGPVClickDidOccur
+{
+ return kGPVClickDidOccur_value;
+}
+
+@end
View
2 GraphPaperFramework/GraphPaperCellController.h
@@ -17,7 +17,7 @@
#import "GraphPaperView.h"
#import "GraphPaperCell.h"
-@interface GraphPaperCellController : CellSource
+@interface GraphPaperCellController : NSObject <CellSource>
@property (assign) GraphPaperView *view;
View
8 GraphPaperFramework/GraphPaperCellController.m
@@ -8,6 +8,8 @@
#import "GraphPaperCellController.h"
#import "GraphPaperCell.h"
+#import "CellSourceConstants.h"
+#import "ClickSourceConstants.h"
#import <TwoKeyDictionaryFramework/TwoKeyMutableDictionary.h>
@implementation GraphPaperCellController
@@ -41,7 +43,8 @@ -(GraphPaperCellController *)initWithView:(GraphPaperView *)v
if (self)
{
NSNotificationCenter *notctr = [NSNotificationCenter defaultCenter];
- [notctr addObserver:self selector:@selector(handleClick:) name:kGPVClickDidOccur object:nil];
+ [notctr addObserver:self selector:@selector(handleClick:)
+ name:[ClickSourceConstants kGPVClickDidOccur] object:nil];
self.view = v;
sinks = [[NSMutableSet alloc] init];
cells = [[TwoKeyMutableDictionary alloc] init];
@@ -52,7 +55,8 @@ -(GraphPaperCellController *)initWithView:(GraphPaperView *)v
-(void)notifySinks
{
- NSNotification *not = [NSNotification notificationWithName:kGPVCellsDidUpdate object:self];
+ NSNotification *not = [NSNotification
+ notificationWithName:[CellSourceConstants kGPVCellsDidUpdate] object:self];
[[NSNotificationCenter defaultCenter] postNotification:not];
}
View
4 GraphPaperFramework/GraphPaperView.h
@@ -11,9 +11,9 @@
#import "CellSource.h"
#import "ClickSource.h"
-@interface GraphPaperView : ClickSource
+@interface GraphPaperView : NSView <ClickSource>
-@property(assign) CellSource *source;
+@property(assign) id<CellSource> source;
@end
View
8 GraphPaperFramework/GraphPaperView.m
@@ -8,6 +8,8 @@
#import "GraphPaperView.h"
#import "GraphPaperCell.h"
+#import "CellSourceConstants.h"
+#import "ClickSourceConstants.h"
@implementation GraphPaperView
@@ -21,7 +23,8 @@ - (id)initWithFrame:(NSRect)frame
self = [super initWithFrame:frame];
if (self) {
NSNotificationCenter *notctr = [NSNotificationCenter defaultCenter];
- [notctr addObserver:self selector:@selector(handleUpdate:) name:kGPVCellsDidUpdate object:nil];
+ [notctr addObserver:self selector:@selector(handleUpdate:)
+ name:[CellSourceConstants kGPVCellsDidUpdate] object:nil];
}
return self;
@@ -76,7 +79,8 @@ -(void)broadcast_click:(NSPoint) loc
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
NSValue *v = [NSValue valueWithPoint:loc];
[data setObject:v forKey:@"point"];
- NSNotification *not = [NSNotification notificationWithName:kGPVClickDidOccur object:self userInfo:data];
+ NSNotification *not = [NSNotification notificationWithName:[ClickSourceConstants kGPVClickDidOccur]
+ object:self userInfo:data];
[[NSNotificationCenter defaultCenter] postNotification:not];
}
View
6 GraphPaperFrameworkStake/AppDelegate.m
@@ -7,7 +7,7 @@
//
#import "AppDelegate.h"
-#import <GraphPaperFramework/CellSource.h>
+#import "CellSourceConstants.h"
#import <GraphPaperFramework/GraphPaperCellController.h>
@interface AppDelegate (private)
@@ -30,8 +30,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
view.source = controller;
NSNotificationCenter *notctr = [NSNotificationCenter defaultCenter];
- [notctr addObserver:self selector:@selector(handleUpdate:) name:kGPVCellsDidUpdate object:nil];
-
+ [notctr addObserver:self selector:@selector(handleUpdate:)
+ name:[CellSourceConstants kGPVCellsDidUpdate] object:nil];
[self doUpdateStatus];
}

0 comments on commit 0474a8c

Please sign in to comment.
Something went wrong with that request. Please try again.