X-Git-Url: http://git.ithinksw.org/ITFoundation.git/blobdiff_plain/6262c31ef1f3b4c4cec3e909f0ecc189eb242ab2..744612b5d258474e367710b870a5caaed7d11ab9:/ITSharedController.m diff --git a/ITSharedController.m b/ITSharedController.m new file mode 100644 index 0000000..1887165 --- /dev/null +++ b/ITSharedController.m @@ -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