Permalink
Browse files

Initial content : Singleton File Template + some TextMacros

  • Loading branch information...
1 parent b76554a commit 2cbe5e5a17aa0b1ec0d1e76ec5d419081d448229 @AliSoftware committed May 25, 2010
@@ -0,0 +1,5 @@
+{
+ MainTemplateFile = "class.m";
+ "CounterpartTemplateFile" = "class.h";
+ Description = "An Objective-C Singleton class file, with an optional header which includes the <Foundation/Foundation> header.";
+}
@@ -0,0 +1,16 @@
+//
+// «FILENAME»
+// «PROJECTNAME»
+//
+// Created by «FULLUSERNAME» on «DATE».
+// Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+@interface «FILEBASENAMEASIDENTIFIER» : NSObject {
+
+}
++ («FILEBASENAMEASIDENTIFIER»*)sharedInstance;
+@end
@@ -0,0 +1,44 @@
+//
+// «FILENAME»
+// «PROJECTNAME»
+//
+// Created by «FULLUSERNAME» on «DATE».
+// Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
+//
+
+«OPTIONALHEADERIMPORTLINE»
+
+@implementation «FILEBASENAMEASIDENTIFIER»
+
+static «FILEBASENAMEASIDENTIFIER»* _sharedInstance = nil;
+
++ («FILEBASENAMEASIDENTIFIER»*)sharedInstance
+{
+ @synchronized(self) {
+ if (_sharedInstance == nil) {
+ [[[self alloc] init] autorelease]; // assignment not done here
+ // "autorelease" is a noop for a Singleton, but is still useful to avoid a Static-Analyzer warning
+ }
+ }
+ return _sharedInstance;
+}
+
++ (id)allocWithZone:(NSZone *)zone
+{
+ @synchronized(self) {
+ if (_sharedInstance == nil) {
+ _sharedInstance = [super allocWithZone:zone];
+ return _sharedInstance; // assignment and return on first allocation
+ }
+ }
+ return nil; //on subsequent allocation attempts return nil
+}
+
+- (id)copyWithZone:(NSZone *)zone { return self; }
+- (id)retain { return self; }
+- (unsigned)retainCount { return UINT_MAX; /* denotes an object that cannot be released */ }
+- (void)release { /* do nothing */ }
+- (id)autorelease { return self; }
+
+@end
+
@@ -0,0 +1,6 @@
+This directory contain some useful File Tempates to add to Xcode, so that you can create new .h/.m files based on those templates.
+
+To install those File Templates on your mac, copy the templates directory into:
+ ~/Library/Application Support/Developer/Shared/Xcode/File Templates
+
+Note that the ".pbfiletemplate" directory should be in a subdirectory (e.g. "Cocoa Class") of the "File Templates" directory to be visible in the Xcode's New File wizard.
@@ -0,0 +1,6 @@
+This directory contain some useful Project Tempates to add to Xcode, so that you can create new Xcode projects based on those templates.
+
+To install those Project Templates on your mac, copy the templates directory into:
+ ~/Library/Application Support/Developer/Shared/Xcode/Project Templates
+
+Note that the directory containing the project template should itself be in a subdirectory (e.g. "Cocoa Application") of the "Project Templates" directory to be visible in the Xcode's New Project wizard.
Oops, something went wrong.

0 comments on commit 2cbe5e5

Please sign in to comment.