From e5d379d0f6d84e15dcaf7dbea75c958f1d9e6b9d Mon Sep 17 00:00:00 2001 From: Doug Scandrett Date: Wed, 20 Nov 2013 22:46:40 -0500 Subject: [PATCH 1/2] Update the Objective-C Class template for UIView to include an empty xib and a factory method. This can be very helpful for managing a complicated subview hierarchy that is easier to manipulate in interface builder versus code. In this case, the File's Owner is not used, and the view itself can manage its own subviews. --- .../UIView/___FILEBASENAME___.h | 27 +++++--------- .../UIView/___FILEBASENAME___.m | 36 ++++++++----------- .../UIView/___FILEBASENAME___.xib | 15 ++++++++ 3 files changed, 38 insertions(+), 40 deletions(-) create mode 100644 Objective-C Class.xctemplate/UIView/___FILEBASENAME___.xib diff --git a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h index d60e876..ceda6b4 100644 --- a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h +++ b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h @@ -1,24 +1,15 @@ -#pragma mark Constants +// +// ___FILENAME___ +// ___PROJECTNAME___ +// +// Created by ___FULLUSERNAME___ on ___DATE___. +// Copyright ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved. +// - -#pragma mark - Enumerations - - -#pragma mark - Class Interface +#import @interface ___FILEBASENAMEASIDENTIFIER___ : UIView - -#pragma mark - Properties - - -#pragma mark - Constructors - - -#pragma mark - Static Methods - - -#pragma mark - Instance Methods - ++ (instancetype)standard___FILEBASENAMEASIDENTIFIER___; @end \ No newline at end of file diff --git a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m index 7236687..93e16a5 100644 --- a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m +++ b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m @@ -1,32 +1,18 @@ -#import "___FILEBASENAME___.h" - - -#pragma mark Constants +// +// ___FILENAME___ +// ___PROJECTNAME___ +// +// Created by ___FULLUSERNAME___ on ___DATE___. +// Copyright ___YEAR___ ___ORGANIZATIONNAME___. All rights reserved. +// - -#pragma mark - Class Extension +#import "___FILEBASENAME___.h" @interface ___FILEBASENAMEASIDENTIFIER___ () - -- (void)_initialize___VARIABLE_className:identifier___; - - @end - -#pragma mark - Class Variables - - -#pragma mark - Class Definition - @implementation ___FILEBASENAMEASIDENTIFIER___ - -#pragma mark - Properties - - -#pragma mark - Constructors - - (id)initWithFrame: (CGRect)frame { // Abort if base initializer fails. @@ -71,5 +57,11 @@ - (void)_initialize___VARIABLE_className:identifier___ // Initialize instance variables. } +#pragma mark - Factory Methods ++ (instancetype)standard___FILEBASENAMEASIDENTIFIER___ +{ + ___FILEBASENAMEASIDENTIFIER___ *view = (___FILEBASENAMEASIDENTIFIER___ *)[[[NSBundle mainBundle] loadNibNamed:@"___FILEBASENAMEASIDENTIFIER___" owner:nil options:nil] objectAtIndex:0]; + return view; +} @end \ No newline at end of file diff --git a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.xib b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.xib new file mode 100644 index 0000000..8457157 --- /dev/null +++ b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.xib @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file From 28fa849c72fd8b296db4b86efea798a2afa2d641 Mon Sep 17 00:00:00 2001 From: Doug Scandrett Date: Wed, 4 Jun 2014 13:19:49 -0400 Subject: [PATCH 2/2] Adjust a few minor formatting issues. --- .../UIView/___FILEBASENAME___.h | 2 +- .../UIView/___FILEBASENAME___.m | 47 +++++-------------- install.sh | 4 +- 3 files changed, 14 insertions(+), 39 deletions(-) diff --git a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h index ceda6b4..2c27a1f 100644 --- a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h +++ b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.h @@ -12,4 +12,4 @@ + (instancetype)standard___FILEBASENAMEASIDENTIFIER___; -@end \ No newline at end of file +@end diff --git a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m index 93e16a5..0d18726 100644 --- a/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m +++ b/Objective-C Class.xctemplate/UIView/___FILEBASENAME___.m @@ -13,55 +13,30 @@ @interface ___FILEBASENAMEASIDENTIFIER___ () @implementation ___FILEBASENAMEASIDENTIFIER___ -- (id)initWithFrame: (CGRect)frame -{ - // Abort if base initializer fails. - if ((self = [super initWithFrame: frame]) == nil) - { +- (id)initWithFrame: (CGRect)frame { + if ((self = [super initWithFrame: frame]) == nil) { return nil; } - - // Initialize view. - [self _initialize___VARIABLE_className:identifier___]; - - // Return initialized instance. - return self; + [self _initialize___VARIABLE_className:identifier___]; + return self; } -- (id)initWithCoder: (NSCoder *)coder -{ - // Abort if base initializer fails. - if ((self = [super initWithCoder: coder]) == nil) - { +- (id)initWithCoder: (NSCoder *)coder { + if ((self = [super initWithCoder: coder]) == nil) { return nil; } - - // Initialize view. - [self _initialize___VARIABLE_className:identifier___]; - - // Return initialized instance. - return self; + [self _initialize___VARIABLE_className:identifier___]; + return self; } - -#pragma mark - Public Methods - - -#pragma mark - Overridden Methods - - -#pragma mark - Private Methods - -- (void)_initialize___VARIABLE_className:identifier___ -{ +- (void)_initialize___VARIABLE_className:identifier___ { // Initialize instance variables. } #pragma mark - Factory Methods -+ (instancetype)standard___FILEBASENAMEASIDENTIFIER___ -{ ++ (instancetype)standard___FILEBASENAMEASIDENTIFIER___ { ___FILEBASENAMEASIDENTIFIER___ *view = (___FILEBASENAMEASIDENTIFIER___ *)[[[NSBundle mainBundle] loadNibNamed:@"___FILEBASENAMEASIDENTIFIER___" owner:nil options:nil] objectAtIndex:0]; return view; } -@end \ No newline at end of file +@end diff --git a/install.sh b/install.sh index c6a0c7d..4483a76 100755 --- a/install.sh +++ b/install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Default the folder name to "1414 Degrees". -folderName="1414 Degrees" +folderName="dssDigital" # Ensure that at most one argument has been passed in. if [ "$#" -eq 1 ] @@ -9,7 +9,7 @@ then folderName=$1 elif [ "$#" -gt 1 ] then - echo -e "This script takes one argument at most.\\ne.g. install.sh \"1414 Degrees\"" + echo -e "This script takes one argument at most.\\ne.g. install.sh \"dssDigital\"" exit 1 fi