Updating ITFoundation to include updates spurred by Haven development.
[ITFoundation.git] / ITSharedController.m
diff --git a/ITSharedController.m b/ITSharedController.m
new file mode 100644 (file)
index 0000000..1887165
--- /dev/null
@@ -0,0 +1,21 @@
+#import "ITSharedController.h"
+
+static NSMutableDictionary *_ITSharedController_sharedControllers = nil;
+
+@implementation ITSharedController
+
++ (id)sharedController {
+       if (!_ITSharedController_sharedControllers) {
+               _ITSharedController_sharedControllers = [[NSMutableDictionary alloc] init];
+       }
+       id thisController;
+       if (thisController = [_ITSharedController_sharedControllers objectForKey:NSStringFromClass(self)]) {
+               return thisController;
+       } else {
+               thisController = [[self alloc] init];
+               [_ITSharedController_sharedControllers setObject:thisController forKey:NSStringFromClass(self)];
+               return thisController;
+       }
+}
+
+@end