├── Custom └── Cocoa Touch Class.xctemplate │ ├── CustomNSObjectObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── NSObjectObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── NSObjectSwift │ └── ___FILEBASENAME___.swift │ ├── TemplateIcon.png │ ├── TemplateIcon@2x.png │ ├── TemplateInfo.plist │ ├── UICollectionReusableViewObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UICollectionReusableViewSwift │ └── ___FILEBASENAME___.swift │ ├── UICollectionReusableViewXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib │ ├── UICollectionReusableViewXIBSwift │ ├── ___FILEBASENAME___.swift │ └── ___FILEBASENAME___.xib │ ├── UICollectionViewCellObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UICollectionViewCellSwift │ └── ___FILEBASENAME___.swift │ ├── UICollectionViewCellXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib │ ├── UICollectionViewCellXIBSwift │ ├── ___FILEBASENAME___.swift │ └── ___FILEBASENAME___.xib │ ├── UICollectionViewControllerObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UICollectionViewControllerSwift │ └── ___FILEBASENAME___.swift │ ├── UICollectionViewControllerXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib │ ├── UICollectionViewControllerXIBSwift │ ├── ___FILEBASENAME___.swift │ └── ___FILEBASENAME___.xib │ ├── UITableViewCellObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UITableViewCellSwift │ └── ___FILEBASENAME___.swift │ ├── UITableViewCellXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib │ ├── UITableViewCellXIBSwift │ ├── ___FILEBASENAME___.swift │ └── ___FILEBASENAME___.xib │ ├── UITableViewControllerObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UITableViewControllerSwift │ └── ___FILEBASENAME___.swift │ ├── UITableViewControllerXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib │ ├── UITableViewControllerXIBSwift │ ├── ___FILEBASENAME___.swift │ └── ___FILEBASENAME___.xib │ ├── UIViewControllerObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UIViewControllerSwift │ └── ___FILEBASENAME___.swift │ ├── UIViewControllerXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib │ ├── UIViewControllerXIBSwift │ ├── ___FILEBASENAME___.swift │ └── ___FILEBASENAME___.xib │ ├── UIViewObjective-C │ ├── ___FILEBASENAME___.h │ └── ___FILEBASENAME___.m │ ├── UIViewSwift │ └── ___FILEBASENAME___.swift │ └── UIViewXIBObjective-C │ ├── ___FILEBASENAME___.h │ ├── ___FILEBASENAME___.m │ └── ___FILEBASENAME___.xib └── README.md /Custom/Cocoa Touch Class.xctemplate/CustomNSObjectObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : NSObject 8 | 9 | /// 销毁单例 10 | - (void)invalidate; 11 | /// 初始化单例 12 | + (___FILEBASENAMEASIDENTIFIER___ *)sharedManager; 13 | 14 | 15 | @end 16 | 17 | NS_ASSUME_NONNULL_END 18 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/CustomNSObjectObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | static dispatch_once_t _onceToken; 6 | static ___FILEBASENAMEASIDENTIFIER___ *_manager; 7 | 8 | @interface ___FILEBASENAMEASIDENTIFIER___() 9 | 10 | @end 11 | 12 | @implementation ___FILEBASENAMEASIDENTIFIER___ 13 | 14 | - (void)invalidate { 15 | _onceToken = 0; 16 | _manager = nil; 17 | } 18 | 19 | + (___FILEBASENAMEASIDENTIFIER___ *)sharedManager { 20 | dispatch_once(&_onceToken, ^{ 21 | _manager = [[super allocWithZone:NULL] init]; 22 | }); 23 | return _manager; 24 | } 25 | 26 | + (instancetype)allocWithZone:(struct _NSZone *)zone{ 27 | return [self sharedManager];; 28 | } 29 | 30 | + (instancetype)new { 31 | return [self alloc]; 32 | } 33 | 34 | - (nonnull id)copyWithZone:(nullable NSZone *)zone { 35 | return self; 36 | } 37 | 38 | - (nonnull id)mutableCopyWithZone:(nullable NSZone *)zone { 39 | return self; 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/NSObjectObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/NSObjectObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @implementation ___FILEBASENAMEASIDENTIFIER___ 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/NSObjectSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/TemplateIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinKangDeveloper/CustomTemplate/2e2bed6412b05be34f2d5d459cd37bdacdc2a73b/Custom/Cocoa Touch Class.xctemplate/TemplateIcon.png -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/TemplateIcon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GavinKangDeveloper/CustomTemplate/2e2bed6412b05be34f2d5d459cd37bdacdc2a73b/Custom/Cocoa Touch Class.xctemplate/TemplateIcon@2x.png -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/TemplateInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Kind 6 | Xcode.IDEFoundation.TextSubstitutionFileTemplateKind 7 | Description 8 | A Cocoa Touch class. 9 | Summary 10 | A Cocoa Touch class 11 | SortOrder 12 | 1 13 | DefaultCompletionName 14 | MyClass 15 | Platforms 16 | 17 | com.apple.platform.iphoneos 18 | 19 | Options 20 | 21 | 22 | Identifier 23 | productName 24 | Required 25 | 26 | Name 27 | Class: 28 | Description 29 | The name of the class to create 30 | Type 31 | text 32 | NotPersisted 33 | 34 | 35 | 36 | Identifier 37 | cocoaTouchSubclass 38 | Required 39 | YES 40 | Name 41 | Subclass of: 42 | Description 43 | What class to subclass in the new file 44 | Type 45 | class 46 | Default 47 | NSObject 48 | FallbackHeader 49 | #import <UIKit/UIKit.h> 50 | Values 51 | 52 | NSObject 53 | UIView 54 | UIViewController 55 | UITableViewController 56 | UITableViewCell 57 | UICollectionViewController 58 | UICollectionViewCell 59 | UICollectionReusableView 60 | 61 | Suffixes 62 | 63 | UIViewController 64 | ViewController 65 | UITableViewController 66 | TableViewController 67 | UITableViewCell 68 | TableViewCell 69 | UICollectionViewController 70 | CollectionViewController 71 | UICollectionViewCell 72 | CollectionViewCell 73 | UICollectionReusableView 74 | CollectionReusableView 75 | 76 | 77 | 78 | Identifier 79 | XIB 80 | Name 81 | Also create XIB file 82 | Description 83 | Whether to create a XIB file with the same name 84 | Type 85 | checkbox 86 | RequiredOptions 87 | 88 | cocoaTouchSubclass 89 | 90 | UIViewController 91 | UITableViewController 92 | UITableViewCell 93 | UICollectionViewController 94 | UICollectionViewCell 95 | UICollectionReusableView 96 | UIView 97 | 98 | 99 | Default 100 | false 101 | NotPersisted 102 | 103 | 104 | 105 | Identifier 106 | languageChoice 107 | Required 108 | 109 | Name 110 | Language: 111 | Description 112 | The implementation language 113 | Type 114 | popup 115 | Default 116 | Objective-C 117 | Values 118 | 119 | Swift 120 | Objective-C 121 | 122 | MainTemplateFiles 123 | 124 | Swift 125 | ___FILEBASENAME___.swift 126 | Objective-C 127 | ___FILEBASENAME___.m 128 | 129 | AllowedTypes 130 | 131 | Swift 132 | 133 | public.swift-source 134 | 135 | Objective-C 136 | 137 | public.objective-c-source 138 | public.objective-c-plus-plus-source 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @implementation ___FILEBASENAMEASIDENTIFIER___ 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @implementation ___FILEBASENAMEASIDENTIFIER___ 6 | 7 | - (void)awakeFromNib { 8 | [super awakeFromNib]; 9 | // Initialization code 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewXIBSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func awakeFromNib() { 8 | super.awakeFromNib() 9 | // Initialization code 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionReusableViewXIBSwift/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | - (void)updateWith:(<# model #> *)<# model #>; 10 | + (CGSize)getSize; 11 | 12 | @end 13 | 14 | NS_ASSUME_NONNULL_END 15 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAME___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (instancetype)initWithFrame:(CGRect)frame { 12 | self = [super initWithFrame:frame]; 13 | if (self) { 14 | 15 | //设置view 16 | [self setupView]; 17 | } 18 | return self; 19 | } 20 | 21 | #pragma mark - View 22 | - (void)setupView { 23 | 24 | } 25 | 26 | #pragma mark - Private 27 | 28 | 29 | #pragma mark - Public 30 | - (void)updateWith:(<# model #> *)<# model #> { 31 | 32 | } 33 | 34 | + (CGSize)getSize { 35 | return CGSizeMake(<#CGFloat width#>, <#CGFloat height#>); 36 | } 37 | 38 | #pragma mark - Setter 39 | 40 | 41 | #pragma mark - Getter 42 | 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | - (void)updateWith:(<# model #> *)<# model #>; 10 | + (CGSize)getSize; 11 | 12 | @end 13 | 14 | NS_ASSUME_NONNULL_END 15 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAME___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)awakeFromNib { 12 | [super awakeFromNib]; 13 | 14 | //设置view 15 | [self setupView]; 16 | } 17 | 18 | #pragma mark - View 19 | - (void)setupView { 20 | 21 | } 22 | 23 | #pragma mark - Private 24 | 25 | 26 | #pragma mark - Public 27 | - (void)updateWith:(<# model #> *)<# model #> { 28 | 29 | } 30 | 31 | + (CGSize)getSize { 32 | return CGSizeMake(<#CGFloat width#>, <#CGFloat height#>); 33 | } 34 | 35 | #pragma mark - Setter 36 | 37 | 38 | #pragma mark - Getter 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellXIBSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func awakeFromNib() { 8 | super.awakeFromNib() 9 | // Initialization code 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewCellXIBSwift/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | static NSString * const reuseIdentifier = @"Cell"; 12 | 13 | - (void)viewDidLoad { 14 | [super viewDidLoad]; 15 | 16 | // Uncomment the following line to preserve selection between presentations 17 | // self.clearsSelectionOnViewWillAppear = NO; 18 | 19 | // Register cell classes 20 | [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; 21 | 22 | // Do any additional setup after loading the view. 23 | } 24 | 25 | /* 26 | #pragma mark - Navigation 27 | 28 | // In a storyboard-based application, you will often want to do a little preparation before navigation 29 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 30 | // Get the new view controller using [segue destinationViewController]. 31 | // Pass the selected object to the new view controller. 32 | } 33 | */ 34 | 35 | #pragma mark 36 | 37 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 38 | #warning Incomplete implementation, return the number of sections 39 | return 0; 40 | } 41 | 42 | 43 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 44 | #warning Incomplete implementation, return the number of items 45 | return 0; 46 | } 47 | 48 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 49 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 50 | 51 | // Configure the cell 52 | 53 | return cell; 54 | } 55 | 56 | #pragma mark 57 | 58 | /* 59 | // Uncomment this method to specify if the specified item should be highlighted during tracking 60 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath { 61 | return YES; 62 | } 63 | */ 64 | 65 | /* 66 | // Uncomment this method to specify if the specified item should be selected 67 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { 68 | return YES; 69 | } 70 | */ 71 | 72 | /* 73 | // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item 74 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath { 75 | return NO; 76 | } 77 | 78 | - (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { 79 | return NO; 80 | } 81 | 82 | - (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { 83 | 84 | } 85 | */ 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | private let reuseIdentifier = "Cell" 6 | 7 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 8 | 9 | override func viewDidLoad() { 10 | super.viewDidLoad() 11 | 12 | // Uncomment the following line to preserve selection between presentations 13 | // self.clearsSelectionOnViewWillAppear = false 14 | 15 | // Register cell classes 16 | self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 17 | 18 | // Do any additional setup after loading the view. 19 | } 20 | 21 | /* 22 | // MARK: - Navigation 23 | 24 | // In a storyboard-based application, you will often want to do a little preparation before navigation 25 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 26 | // Get the new view controller using [segue destinationViewController]. 27 | // Pass the selected object to the new view controller. 28 | } 29 | */ 30 | 31 | // MARK: UICollectionViewDataSource 32 | 33 | override func numberOfSections(in collectionView: UICollectionView) -> Int { 34 | // #warning Incomplete implementation, return the number of sections 35 | return 0 36 | } 37 | 38 | 39 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 40 | // #warning Incomplete implementation, return the number of items 41 | return 0 42 | } 43 | 44 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 45 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) 46 | 47 | // Configure the cell 48 | 49 | return cell 50 | } 51 | 52 | // MARK: UICollectionViewDelegate 53 | 54 | /* 55 | // Uncomment this method to specify if the specified item should be highlighted during tracking 56 | override func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool { 57 | return true 58 | } 59 | */ 60 | 61 | /* 62 | // Uncomment this method to specify if the specified item should be selected 63 | override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { 64 | return true 65 | } 66 | */ 67 | 68 | /* 69 | // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item 70 | override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool { 71 | return false 72 | } 73 | 74 | override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool { 75 | return false 76 | } 77 | 78 | override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) { 79 | 80 | } 81 | */ 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | static NSString * const reuseIdentifier = @"Cell"; 12 | 13 | - (void)viewDidLoad { 14 | [super viewDidLoad]; 15 | 16 | // Uncomment the following line to preserve selection between presentations 17 | // self.clearsSelectionOnViewWillAppear = NO; 18 | 19 | // Register cell classes 20 | [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:reuseIdentifier]; 21 | 22 | // Do any additional setup after loading the view. 23 | } 24 | 25 | /* 26 | #pragma mark - Navigation 27 | 28 | // In a storyboard-based application, you will often want to do a little preparation before navigation 29 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 30 | // Get the new view controller using [segue destinationViewController]. 31 | // Pass the selected object to the new view controller. 32 | } 33 | */ 34 | 35 | #pragma mark 36 | 37 | - (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView { 38 | #warning Incomplete implementation, return the number of sections 39 | return 0; 40 | } 41 | 42 | 43 | - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { 44 | #warning Incomplete implementation, return the number of items 45 | return 0; 46 | } 47 | 48 | - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { 49 | UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:reuseIdentifier forIndexPath:indexPath]; 50 | 51 | // Configure the cell 52 | 53 | return cell; 54 | } 55 | 56 | #pragma mark 57 | 58 | /* 59 | // Uncomment this method to specify if the specified item should be highlighted during tracking 60 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldHighlightItemAtIndexPath:(NSIndexPath *)indexPath { 61 | return YES; 62 | } 63 | */ 64 | 65 | /* 66 | // Uncomment this method to specify if the specified item should be selected 67 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldSelectItemAtIndexPath:(NSIndexPath *)indexPath { 68 | return YES; 69 | } 70 | */ 71 | 72 | /* 73 | // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item 74 | - (BOOL)collectionView:(UICollectionView *)collectionView shouldShowMenuForItemAtIndexPath:(NSIndexPath *)indexPath { 75 | return NO; 76 | } 77 | 78 | - (BOOL)collectionView:(UICollectionView *)collectionView canPerformAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { 79 | return NO; 80 | } 81 | 82 | - (void)collectionView:(UICollectionView *)collectionView performAction:(SEL)action forItemAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender { 83 | 84 | } 85 | */ 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerXIBSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | private let reuseIdentifier = "Cell" 6 | 7 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 8 | 9 | override func viewDidLoad() { 10 | super.viewDidLoad() 11 | 12 | // Uncomment the following line to preserve selection between presentations 13 | // self.clearsSelectionOnViewWillAppear = false 14 | 15 | // Register cell classes 16 | self.collectionView!.register(UICollectionViewCell.self, forCellWithReuseIdentifier: reuseIdentifier) 17 | 18 | // Do any additional setup after loading the view. 19 | } 20 | 21 | /* 22 | // MARK: - Navigation 23 | 24 | // In a storyboard-based application, you will often want to do a little preparation before navigation 25 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 26 | // Get the new view controller using [segue destinationViewController]. 27 | // Pass the selected object to the new view controller. 28 | } 29 | */ 30 | 31 | // MARK: UICollectionViewDataSource 32 | 33 | override func numberOfSections(in collectionView: UICollectionView) -> Int { 34 | // #warning Incomplete implementation, return the number of sections 35 | return 0 36 | } 37 | 38 | 39 | override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 40 | // #warning Incomplete implementation, return the number of items 41 | return 0 42 | } 43 | 44 | override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 45 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) 46 | 47 | // Configure the cell 48 | 49 | return cell 50 | } 51 | 52 | // MARK: UICollectionViewDelegate 53 | 54 | /* 55 | // Uncomment this method to specify if the specified item should be highlighted during tracking 56 | override func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool { 57 | return true 58 | } 59 | */ 60 | 61 | /* 62 | // Uncomment this method to specify if the specified item should be selected 63 | override func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool { 64 | return true 65 | } 66 | */ 67 | 68 | /* 69 | // Uncomment these methods to specify if an action menu should be displayed for the specified item, and react to actions performed on the item 70 | override func collectionView(_ collectionView: UICollectionView, shouldShowMenuForItemAt indexPath: IndexPath) -> Bool { 71 | return false 72 | } 73 | 74 | override func collectionView(_ collectionView: UICollectionView, canPerformAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) -> Bool { 75 | return false 76 | } 77 | 78 | override func collectionView(_ collectionView: UICollectionView, performAction action: Selector, forItemAt indexPath: IndexPath, withSender sender: Any?) { 79 | 80 | } 81 | */ 82 | 83 | } 84 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UICollectionViewControllerXIBSwift/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | - (void)updateWith:(<# model #> *)<# model #>; 10 | + (CGFloat)getHeight; 11 | 12 | @end 13 | 14 | NS_ASSUME_NONNULL_END 15 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAME___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 12 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 13 | if (self) { 14 | 15 | //设置view 16 | [self setupView]; 17 | } 18 | return self; 19 | } 20 | 21 | #pragma mark - View 22 | - (void)setupView { 23 | 24 | } 25 | 26 | #pragma mark - Private 27 | 28 | 29 | #pragma mark - Public 30 | - (void)updateWith:(<# model #> *)<# model #> { 31 | 32 | } 33 | 34 | + (CGFloat)getHeight { 35 | return <# height #>; 36 | } 37 | 38 | #pragma mark - Setter 39 | 40 | 41 | #pragma mark - Getter 42 | 43 | 44 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 45 | [super setSelected:selected animated:animated]; 46 | 47 | // Configure the view for the selected state 48 | } 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func awakeFromNib() { 8 | super.awakeFromNib() 9 | // Initialization code 10 | } 11 | 12 | override func setSelected(_ selected: Bool, animated: Bool) { 13 | super.setSelected(selected, animated: animated) 14 | 15 | // Configure the view for the selected state 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | - (void)updateWith:(<# model #> *)<# model #>; 10 | + (CGFloat)getHeight; 11 | 12 | @end 13 | 14 | NS_ASSUME_NONNULL_END 15 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAME___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)awakeFromNib { 12 | [super awakeFromNib]; 13 | 14 | //设置view 15 | [self setupView]; 16 | } 17 | 18 | #pragma mark - View 19 | - (void)setupView { 20 | 21 | } 22 | 23 | #pragma mark - Private 24 | 25 | 26 | #pragma mark - Public 27 | - (void)updateWith:(<# model #> *)<# model #> { 28 | 29 | } 30 | 31 | + (CGFloat)getHeight { 32 | return <# height #>; 33 | } 34 | 35 | #pragma mark - Setter 36 | 37 | 38 | #pragma mark - Getter 39 | 40 | 41 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 42 | [super setSelected:selected animated:animated]; 43 | 44 | // Configure the view for the selected state 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellXIBSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func awakeFromNib() { 8 | super.awakeFromNib() 9 | // Initialization code 10 | } 11 | 12 | override func setSelected(_ selected: Bool, animated: Bool) { 13 | super.setSelected(selected, animated: animated) 14 | 15 | // Configure the view for the selected state 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewCellXIBSwift/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)viewDidLoad { 12 | [super viewDidLoad]; 13 | 14 | // Uncomment the following line to preserve selection between presentations. 15 | // self.clearsSelectionOnViewWillAppear = NO; 16 | 17 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 18 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; 19 | } 20 | 21 | #pragma mark - Table view data source 22 | 23 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 24 | #warning Incomplete implementation, return the number of sections 25 | return 0; 26 | } 27 | 28 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 29 | #warning Incomplete implementation, return the number of rows 30 | return 0; 31 | } 32 | 33 | /* 34 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 35 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; 36 | 37 | // Configure the cell... 38 | 39 | return cell; 40 | } 41 | */ 42 | 43 | /* 44 | // Override to support conditional editing of the table view. 45 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 46 | // Return NO if you do not want the specified item to be editable. 47 | return YES; 48 | } 49 | */ 50 | 51 | /* 52 | // Override to support editing the table view. 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 54 | if (editingStyle == UITableViewCellEditingStyleDelete) { 55 | // Delete the row from the data source 56 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 57 | } else if (editingStyle == UITableViewCellEditingStyleInsert) { 58 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 59 | } 60 | } 61 | */ 62 | 63 | /* 64 | // Override to support rearranging the table view. 65 | - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 66 | } 67 | */ 68 | 69 | /* 70 | // Override to support conditional rearranging of the table view. 71 | - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 72 | // Return NO if you do not want the item to be re-orderable. 73 | return YES; 74 | } 75 | */ 76 | 77 | /* 78 | #pragma mark - Navigation 79 | 80 | // In a storyboard-based application, you will often want to do a little preparation before navigation 81 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 82 | // Get the new view controller using [segue destinationViewController]. 83 | // Pass the selected object to the new view controller. 84 | } 85 | */ 86 | 87 | @end 88 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func viewDidLoad() { 8 | super.viewDidLoad() 9 | 10 | // Uncomment the following line to preserve selection between presentations 11 | // self.clearsSelectionOnViewWillAppear = false 12 | 13 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 14 | // self.navigationItem.rightBarButtonItem = self.editButtonItem 15 | } 16 | 17 | // MARK: - Table view data source 18 | 19 | override func numberOfSections(in tableView: UITableView) -> Int { 20 | // #warning Incomplete implementation, return the number of sections 21 | return 0 22 | } 23 | 24 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 25 | // #warning Incomplete implementation, return the number of rows 26 | return 0 27 | } 28 | 29 | /* 30 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 31 | let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) 32 | 33 | // Configure the cell... 34 | 35 | return cell 36 | } 37 | */ 38 | 39 | /* 40 | // Override to support conditional editing of the table view. 41 | override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 42 | // Return false if you do not want the specified item to be editable. 43 | return true 44 | } 45 | */ 46 | 47 | /* 48 | // Override to support editing the table view. 49 | override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { 50 | if editingStyle == .delete { 51 | // Delete the row from the data source 52 | tableView.deleteRows(at: [indexPath], with: .fade) 53 | } else if editingStyle == .insert { 54 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 55 | } 56 | } 57 | */ 58 | 59 | /* 60 | // Override to support rearranging the table view. 61 | override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { 62 | 63 | } 64 | */ 65 | 66 | /* 67 | // Override to support conditional rearranging of the table view. 68 | override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { 69 | // Return false if you do not want the item to be re-orderable. 70 | return true 71 | } 72 | */ 73 | 74 | /* 75 | // MARK: - Navigation 76 | 77 | // In a storyboard-based application, you will often want to do a little preparation before navigation 78 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 79 | // Get the new view controller using segue.destination. 80 | // Pass the selected object to the new view controller. 81 | } 82 | */ 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | - (void)viewDidLoad { 12 | [super viewDidLoad]; 13 | 14 | // Uncomment the following line to preserve selection between presentations. 15 | // self.clearsSelectionOnViewWillAppear = NO; 16 | 17 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 18 | // self.navigationItem.rightBarButtonItem = self.editButtonItem; 19 | } 20 | 21 | #pragma mark - Table view data source 22 | 23 | - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 24 | #warning Incomplete implementation, return the number of sections 25 | return 0; 26 | } 27 | 28 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 29 | #warning Incomplete implementation, return the number of rows 30 | return 0; 31 | } 32 | 33 | /* 34 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 35 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath]; 36 | 37 | // Configure the cell... 38 | 39 | return cell; 40 | } 41 | */ 42 | 43 | /* 44 | // Override to support conditional editing of the table view. 45 | - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { 46 | // Return NO if you do not want the specified item to be editable. 47 | return YES; 48 | } 49 | */ 50 | 51 | /* 52 | // Override to support editing the table view. 53 | - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { 54 | if (editingStyle == UITableViewCellEditingStyleDelete) { 55 | // Delete the row from the data source 56 | [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade]; 57 | } else if (editingStyle == UITableViewCellEditingStyleInsert) { 58 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 59 | } 60 | } 61 | */ 62 | 63 | /* 64 | // Override to support rearranging the table view. 65 | - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath { 66 | } 67 | */ 68 | 69 | /* 70 | // Override to support conditional rearranging of the table view. 71 | - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { 72 | // Return NO if you do not want the item to be re-orderable. 73 | return YES; 74 | } 75 | */ 76 | 77 | /* 78 | #pragma mark - Table view delegate 79 | 80 | // In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath: 81 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 82 | // Navigation logic may go here, for example: 83 | // Create the next view controller. 84 | <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil]; 85 | 86 | // Pass the selected object to the new view controller. 87 | 88 | // Push the view controller. 89 | [self.navigationController pushViewController:detailViewController animated:YES]; 90 | } 91 | */ 92 | 93 | /* 94 | #pragma mark - Navigation 95 | 96 | // In a storyboard-based application, you will often want to do a little preparation before navigation 97 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 98 | // Get the new view controller using [segue destinationViewController]. 99 | // Pass the selected object to the new view controller. 100 | } 101 | */ 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerXIBSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func viewDidLoad() { 8 | super.viewDidLoad() 9 | 10 | // Uncomment the following line to preserve selection between presentations 11 | // self.clearsSelectionOnViewWillAppear = false 12 | 13 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller. 14 | // self.navigationItem.rightBarButtonItem = self.editButtonItem 15 | } 16 | 17 | // MARK: - Table view data source 18 | 19 | override func numberOfSections(in tableView: UITableView) -> Int { 20 | // #warning Incomplete implementation, return the number of sections 21 | return 0 22 | } 23 | 24 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 25 | // #warning Incomplete implementation, return the number of rows 26 | return 0 27 | } 28 | 29 | /* 30 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 31 | let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath) 32 | 33 | // Configure the cell... 34 | 35 | return cell 36 | } 37 | */ 38 | 39 | /* 40 | // Override to support conditional editing of the table view. 41 | override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool { 42 | // Return false if you do not want the specified item to be editable. 43 | return true 44 | } 45 | */ 46 | 47 | /* 48 | // Override to support editing the table view. 49 | override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { 50 | if editingStyle == .delete { 51 | // Delete the row from the data source 52 | tableView.deleteRows(at: [indexPath], with: .fade) 53 | } else if editingStyle == .insert { 54 | // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view 55 | } 56 | } 57 | */ 58 | 59 | /* 60 | // Override to support rearranging the table view. 61 | override func tableView(_ tableView: UITableView, moveRowAt fromIndexPath: IndexPath, to: IndexPath) { 62 | 63 | } 64 | */ 65 | 66 | /* 67 | // Override to support conditional rearranging of the table view. 68 | override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { 69 | // Return false if you do not want the item to be re-orderable. 70 | return true 71 | } 72 | */ 73 | 74 | /* 75 | // MARK: - Navigation 76 | 77 | // In a storyboard-based application, you will often want to do a little preparation before navigation 78 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 79 | // Get the new view controller using segue.destination. 80 | // Pass the selected object to the new view controller. 81 | } 82 | */ 83 | 84 | } 85 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UITableViewControllerXIBSwift/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | #pragma mark - LifeCycle 12 | - (void)dealloc { 13 | [self removeNotificationObserver]; 14 | } 15 | 16 | -(void)viewWillAppear:(BOOL)animated { 17 | [super viewWillAppear:animated]; 18 | 19 | } 20 | 21 | - (void)viewWillDisappear:(BOOL)animated { 22 | [super viewWillDisappear:animated]; 23 | 24 | } 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | //设置导航栏 30 | [self setupNavBar]; 31 | 32 | //设置view 33 | [self setupView]; 34 | 35 | //请求数据 36 | [self requestData]; 37 | 38 | //添加通知 39 | [self addNotificationObserver]; 40 | } 41 | 42 | #pragma mark - View 43 | - (void)setupNavBar { 44 | 45 | } 46 | 47 | - (void)setupView { 48 | 49 | } 50 | 51 | #pragma mark - Network 52 | - (void)requestData { 53 | 54 | } 55 | 56 | #pragma mark- Delegate 57 | #pragma mark UITableDatasource & UITableviewDelegate 58 | 59 | 60 | #pragma mark - Private 61 | 62 | 63 | #pragma mark - Event 64 | 65 | 66 | #pragma mark - Public 67 | 68 | 69 | #pragma mark - NSNotificationCenter 70 | - (void)addNotificationObserver { 71 | 72 | } 73 | 74 | - (void)removeNotificationObserver { 75 | 76 | } 77 | 78 | #pragma mark - Setter 79 | 80 | 81 | #pragma mark - Getter 82 | 83 | 84 | #pragma mark - MemoryWarning 85 | - (void)didReceiveMemoryWarning { 86 | 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func viewDidLoad() { 8 | super.viewDidLoad() 9 | 10 | // Do any additional setup after loading the view. 11 | } 12 | 13 | 14 | /* 15 | // MARK: - Navigation 16 | 17 | // In a storyboard-based application, you will often want to do a little preparation before navigation 18 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 19 | // Get the new view controller using segue.destination. 20 | // Pass the selected object to the new view controller. 21 | } 22 | */ 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | #pragma mark - LifeCycle 12 | - (void)dealloc { 13 | [self removeNotificationObserver]; 14 | } 15 | 16 | -(void)viewWillAppear:(BOOL)animated { 17 | [super viewWillAppear:animated]; 18 | 19 | } 20 | 21 | - (void)viewWillDisappear:(BOOL)animated { 22 | [super viewWillDisappear:animated]; 23 | 24 | } 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | //设置导航栏 30 | [self setupNavBar]; 31 | 32 | //设置view 33 | [self setupView]; 34 | 35 | //请求数据 36 | [self requestData]; 37 | 38 | //添加通知 39 | [self addNotificationObserver]; 40 | } 41 | 42 | #pragma mark - View 43 | - (void)setupNavBar { 44 | 45 | } 46 | 47 | - (void)setupView { 48 | 49 | } 50 | 51 | #pragma mark - Network 52 | - (void)requestData { 53 | 54 | } 55 | 56 | #pragma mark- Delegate 57 | #pragma mark UITableDatasource & UITableviewDelegate 58 | 59 | 60 | #pragma mark - Private 61 | 62 | 63 | #pragma mark - Event 64 | 65 | 66 | #pragma mark - Public 67 | 68 | 69 | #pragma mark - NSNotificationCenter 70 | - (void)addNotificationObserver { 71 | 72 | } 73 | 74 | - (void)removeNotificationObserver { 75 | 76 | } 77 | 78 | #pragma mark - Setter 79 | 80 | 81 | #pragma mark - Getter 82 | 83 | 84 | #pragma mark - MemoryWarning 85 | - (void)didReceiveMemoryWarning { 86 | 87 | } 88 | 89 | @end 90 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerXIBSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | override func viewDidLoad() { 8 | super.viewDidLoad() 9 | 10 | // Do any additional setup after loading the view. 11 | } 12 | 13 | 14 | /* 15 | // MARK: - Navigation 16 | 17 | // In a storyboard-based application, you will often want to do a little preparation before navigation 18 | override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 19 | // Get the new view controller using segue.destination. 20 | // Pass the selected object to the new view controller. 21 | } 22 | */ 23 | 24 | } 25 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewControllerXIBSwift/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | NS_ASSUME_NONNULL_BEGIN 6 | 7 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 8 | 9 | @end 10 | 11 | NS_ASSUME_NONNULL_END 12 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAME___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | #pragma mark - LifeCycle 12 | - (void)dealloc { 13 | [self removeNotificationObserver]; 14 | } 15 | 16 | - (instancetype)init { 17 | self = [super init]; 18 | if (self) { 19 | //设置view 20 | [self setupView]; 21 | 22 | //请求数据 23 | [self requestData]; 24 | 25 | //添加通知 26 | [self addNotificationObserver]; 27 | } 28 | return self; 29 | } 30 | 31 | #pragma mark - View 32 | - (void)setupView { 33 | 34 | } 35 | 36 | #pragma mark - Network 37 | - (void)requestData { 38 | 39 | } 40 | 41 | #pragma mark- Delegate 42 | #pragma mark UITableDatasource & UITableviewDelegate 43 | 44 | 45 | #pragma mark - Private 46 | 47 | 48 | #pragma mark - Event 49 | 50 | 51 | #pragma mark - Public 52 | 53 | 54 | #pragma mark - NSNotificationCenter 55 | - (void)addNotificationObserver { 56 | 57 | } 58 | 59 | - (void)removeNotificationObserver { 60 | 61 | } 62 | 63 | #pragma mark - Setter 64 | 65 | 66 | #pragma mark - Getter 67 | 68 | 69 | @end 70 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewSwift/___FILEBASENAME___.swift: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | import UIKit 4 | 5 | class ___FILEBASENAMEASIDENTIFIER___: ___VARIABLE_cocoaTouchSubclass___ { 6 | 7 | /* 8 | // Only override draw() if you perform custom drawing. 9 | // An empty implementation adversely affects performance during animation. 10 | override func draw(_ rect: CGRect) { 11 | // Drawing code 12 | } 13 | */ 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewXIBObjective-C/___FILEBASENAME___.h: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | ___IMPORTHEADER_cocoaTouchSubclass___ 4 | 5 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewXIBObjective-C/___FILEBASENAME___.m: -------------------------------------------------------------------------------- 1 | //___FILEHEADER___ 2 | 3 | #import "___FILEBASENAME___.h" 4 | 5 | @interface ___FILEBASENAME___ () 6 | 7 | @end 8 | 9 | @implementation ___FILEBASENAMEASIDENTIFIER___ 10 | 11 | #pragma mark - LifeCycle 12 | - (void)dealloc { 13 | [self removeNotificationObserver]; 14 | } 15 | 16 | - (void)awakeFromNib { 17 | [super awakeFromNib]; 18 | //设置view 19 | [self setupView]; 20 | 21 | //请求数据 22 | [self requestData]; 23 | 24 | //设置通知 25 | [self addNotificationObserver]; 26 | } 27 | 28 | #pragma mark - View 29 | - (void)setupView { 30 | 31 | } 32 | 33 | #pragma mark - Network 34 | - (void)requestData { 35 | 36 | } 37 | 38 | #pragma mark- Delegate 39 | #pragma mark UITableDatasource & UITableviewDelegate 40 | 41 | 42 | #pragma mark - Private 43 | 44 | 45 | #pragma mark - Event 46 | 47 | 48 | #pragma mark - Public 49 | 50 | 51 | #pragma mark - NSNotificationCenter 52 | - (void)addNotificationObserver { 53 | 54 | } 55 | 56 | - (void)removeNotificationObserver { 57 | 58 | } 59 | 60 | #pragma mark - Setter 61 | 62 | 63 | #pragma mark - Getter 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /Custom/Cocoa Touch Class.xctemplate/UIViewXIBObjective-C/___FILEBASENAME___.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CustomTemplate 2 | [掘金 - 自定义 Xcode 初始化的模板](https://juejin.im/post/6882678008415518734/) 3 | 4 | **为了统一多人开发文件的框架,也为了提高开发效率,降低无效的作业,总结了以下自定义的模板,仅供大家参考,如果对你或者公司有用,[还请到 Github 下载文件的同时,绅士的给个 star ,你的 star ,也是我分享的动力](https://github.com/GavinKangDeveloper/CustomTemplate)。** 5 | 6 | - 系统模板所在位置: 7 | 8 | ``` 9 | /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/File Templates/Source/Cocoa Touch Class.xctemplate 10 | ``` 11 | 自己可以根据需求,直接修改系统默认的文件模版,但是遇到Xcode 升级之类的会覆盖掉原有的文件模版,也可以自定义的模板。 12 | 13 | - 自定义模板目录: 14 | 15 | 如果之前没有自定义过模板,需要根据如下目录,创建对应的文件夹 16 | ``` 17 | ~/Library/Developer/Xcode/Templates/<自定义名>/<自定义名>.xctemplate 18 | ``` 19 | 20 | ![系统的内容](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a4d1b1bf4cf34c14afaaafa33a9e2bc0~tplv-k3u1fbpfcp-watermark.image) 21 | 22 | ### 自定义模板 23 | #### 模板常用的占位宏 24 | - `___PROJECTNAME___`:工程名 25 | - `___FILENAME___`:包含后缀的文件名 26 | - `___FILEBASENAME___` : 文件名 27 | - `___FILEBASENAMEASIDENTIFIER___` :不包含后缀的c格式文件名 28 | - `___VARIABLE_cocoaTouchSubclass___`:继承的父类名字 29 | - `___FULLUSERNAME___`:用户名 30 | - `___ORGANIZATIONNAME___`:公司名 31 | - `___COPYRIGHT___`:版权说明 32 | - `___DATE___`:当前日期 33 | - `___TIME___`:当前时间 34 | - `___YEAR___`:当前年 35 | - `___FILEHEADER___`:默认类的头文件 36 | 37 | #### 自定义模板 38 | 创建自定义模板,首先要把系统的文件, Copy 到在对应的路径下,本次以 `~/Library/Developer/Xcode/Templates/Custom/Cocoa Touch Class.xctemplate ` 路径讲解。下图是自定义模板定制成功后,`command + n ` 后创建类的效果图,我们自定义创建的模板入口一般在 `Other` 的下面。 39 | 40 | ![自定义模板内容](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/bb9ee75a8f154c2382b108cfb261b440~tplv-k3u1fbpfcp-watermark.image) 41 | 42 | ![自定义模板的效果](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/a9e7237539bc4f6c90c4f72fc13edd27~tplv-k3u1fbpfcp-watermark.image) 43 | 44 | ![新文件选择项](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/edb5fd31b8d5447592c83af1ed61cb9d~tplv-k3u1fbpfcp-watermark.image) 45 | 46 | - 注意: 47 | 48 | 1、Xcode 需要 `.xctemplate`后缀才能将这些目录识别为模板。 49 | 2、自定义模板需要重启 Xcode 才生效 50 | 51 | 一个模板通常包含以下文件: 52 | - Custom:选择新文件模板的自定义标题 53 | - TemplateIcon.png 和 TemplateIcon@2x.png 是 Xcode 创建文件界面的图标 54 | - TemplateInfo.plist 中的内容对应 Choose options for your new file: 中的四个选项 55 | - 文件夹中的 `___FILEBASENAME___` 是自定义的 .h 和 .m 文件模板 56 | 57 | #### TemplateInfo.plist 讲解 58 | ![TemplateInfo.plist](https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/e131a069235042a986413cc320f9a220~tplv-k3u1fbpfcp-watermark.image) 59 | 60 | 里面的四个 item 对应 Choose options for your new file 里面的四个选项,我们这里主要讲解自定义 UIView 模板用到的 item2 ,里面的 cocoaTouchSubclass 数组保存的是可选使用 XIB 的类名,比如这里新增了 UIView 可选 XIB 功能,所以需要在 cocoaTouchSubclass 中新增 UIView 项,同时在 Cocoa Touch Class.xctemplate 文件夹中需要新增 UIViewXIBObjective-C 文件夹和对应的文件,否则 UIView 选择创建 XIB ,也没有作用,不会创建任何类。 61 | 62 | 当然,这里面的功能很强大,修改还有默认的 Class 、 Subclass of、XIB 的默认选中等功能,具体还需要大家挖掘。 63 | 64 | [下面具体的修改代码中,没有涉及到修改 XIB 的例子,实际 Github 中已经有了,其原理也是根据上面模板常用的占位宏进行对应修改的,具体可以看 Github,如果对你有帮助,请绅士的 star 吧。](https://github.com/GavinKangDeveloper/CustomTemplate) 65 | 66 | 67 | ### 修改常用模板 68 | 69 | 注意:修改模板的时候不要用 Xcode 打开,用 Xcode 可能会无法修改,可以用文本编辑进行修改,下面修改到的内容有:在 UIViewController、UIView、UITableViewCell、UICollectionViewCell 文件中新增了纯代码和 XIB 特殊注释和初始化需要的方法,UIView新增了可选创建对应的 XIB ,UITableViewCell 和 UICollectionViewCell 新增了对应类名的 Identitier。 70 | 71 | #### UIViewControllerObjective-C & UIViewControllerXIBObjective-C 72 | 73 | ``` 74 | #pragma mark - LifeCycle 75 | - (void)dealloc { 76 | [self removeNotificationObserver]; 77 | } 78 | 79 | -(void)viewWillAppear:(BOOL)animated { 80 | [super viewWillAppear:animated]; 81 | 82 | } 83 | 84 | - (void)viewWillDisappear:(BOOL)animated { 85 | [super viewWillDisappear:animated]; 86 | 87 | } 88 | 89 | - (void)viewDidLoad { 90 | [super viewDidLoad]; 91 | 92 | //设置导航栏 93 | [self setupNavBar]; 94 | 95 | //设置view 96 | [self setupView]; 97 | 98 | //请求数据 99 | [self requestData]; 100 | 101 | //添加通知 102 | [self addNotificationObserver]; 103 | } 104 | 105 | #pragma mark - View 106 | - (void)setupNavBar { 107 | 108 | } 109 | 110 | - (void)setupView { 111 | 112 | } 113 | 114 | #pragma mark - Network 115 | - (void)requestData { 116 | 117 | } 118 | 119 | #pragma mark- Delegate 120 | #pragma mark UITableDatasource & UITableviewDelegate 121 | 122 | 123 | #pragma mark - Private 124 | 125 | 126 | #pragma mark - Event 127 | 128 | 129 | #pragma mark - Public 130 | 131 | 132 | #pragma mark - NSNotificationCenter 133 | - (void)addNotificationObserver { 134 | 135 | } 136 | 137 | - (void)removeNotificationObserver { 138 | 139 | } 140 | 141 | #pragma mark - Setter 142 | 143 | 144 | #pragma mark - Getter 145 | 146 | 147 | #pragma mark - MemoryWarning 148 | - (void)didReceiveMemoryWarning { 149 | 150 | } 151 | ``` 152 | 153 | #### UIViewObjective-C & UIViewXIBObjective-C 154 | 155 | ``` 156 | //___FILEHEADER___ 157 | 158 | #import "___FILEBASENAME___.h" 159 | 160 | @interface ___FILEBASENAME___ () 161 | 162 | @end 163 | 164 | @implementation ___FILEBASENAMEASIDENTIFIER___ 165 | 166 | #pragma mark - LifeCycle 167 | - (void)dealloc { 168 | [self removeNotificationObserver]; 169 | } 170 | 171 | 172 | - (instancetype)init { 173 | self = [super init]; 174 | if (self) { 175 | //设置view 176 | [self setupView]; 177 | 178 | //请求数据 179 | [self requestData]; 180 | 181 | //添加通知 182 | [self addNotificationObserver]; 183 | } 184 | return self; 185 | } 186 | 187 | 188 | - (void)awakeFromNib { 189 | [super awakeFromNib]; 190 | //设置view 191 | [self setupView]; 192 | 193 | //请求数据 194 | [self requestData]; 195 | 196 | //设置通知 197 | [self addNotificationObserver]; 198 | } 199 | 200 | #pragma mark - View 201 | - (void)setupView { 202 | 203 | } 204 | 205 | #pragma mark - Network 206 | - (void)requestData { 207 | 208 | } 209 | 210 | #pragma mark- Delegate 211 | #pragma mark UITableDatasource & UITableviewDelegate 212 | 213 | 214 | #pragma mark - Private 215 | 216 | 217 | #pragma mark - Event 218 | 219 | 220 | #pragma mark - Public 221 | 222 | 223 | #pragma mark - NSNotificationCenter 224 | - (void)addNotificationObserver { 225 | 226 | } 227 | 228 | - (void)removeNotificationObserver { 229 | 230 | } 231 | 232 | #pragma mark - Setter 233 | 234 | 235 | #pragma mark - Getter 236 | 237 | 238 | @end 239 | 240 | ``` 241 | 242 | #### UITableViewCellObjective-C & UITableViewCellXIBObjective-C 243 | 244 | .h 文件 245 | ``` 246 | //___FILEHEADER___ 247 | 248 | ___IMPORTHEADER_cocoaTouchSubclass___ 249 | 250 | NS_ASSUME_NONNULL_BEGIN 251 | 252 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 253 | 254 | - (void)updateWith:(<# model #> *)<# model #>; 255 | + (CGFloat)getHeight; 256 | 257 | @end 258 | 259 | NS_ASSUME_NONNULL_END 260 | 261 | ``` 262 | 263 | .m 文件 264 | ``` 265 | //___FILEHEADER___ 266 | 267 | #import "___FILEBASENAME___.h" 268 | 269 | @interface ___FILEBASENAME___ () 270 | 271 | @end 272 | 273 | @implementation ___FILEBASENAMEASIDENTIFIER___ 274 | 275 | 276 | - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { 277 | self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; 278 | if (self) { 279 | 280 | //设置view 281 | [self setupView]; 282 | } 283 | return self; 284 | } 285 | 286 | 287 | - (void)awakeFromNib { 288 | [super awakeFromNib]; 289 | 290 | //设置view 291 | [self setupView]; 292 | } 293 | 294 | #pragma mark - View 295 | - (void)setupView { 296 | 297 | } 298 | 299 | #pragma mark - Private 300 | 301 | 302 | #pragma mark - Public 303 | - (void)updateWith:(<# model #> *)<# model #> { 304 | 305 | } 306 | 307 | + (CGFloat)getHeight { 308 | return <# height #>; 309 | } 310 | 311 | #pragma mark - Setter 312 | 313 | 314 | #pragma mark - Getter 315 | 316 | 317 | - (void)setSelected:(BOOL)selected animated:(BOOL)animated { 318 | [super setSelected:selected animated:animated]; 319 | 320 | // Configure the view for the selected state 321 | } 322 | 323 | @end 324 | 325 | ``` 326 | #### UICollectionViewCellObjective-C & UICollectionViewCellXIBObjective-C 327 | .h 文件 328 | 329 | ``` 330 | //___FILEHEADER___ 331 | 332 | ___IMPORTHEADER_cocoaTouchSubclass___ 333 | 334 | NS_ASSUME_NONNULL_BEGIN 335 | 336 | @interface ___FILEBASENAMEASIDENTIFIER___ : ___VARIABLE_cocoaTouchSubclass___ 337 | 338 | - (void)updateWith:(<# model #> *)<# model #>; 339 | + (CGSize)getSize; 340 | 341 | @end 342 | 343 | NS_ASSUME_NONNULL_END 344 | ``` 345 | 346 | .m 文件 347 | 348 | ``` 349 | //___FILEHEADER___ 350 | 351 | #import "___FILEBASENAME___.h" 352 | 353 | @interface ___FILEBASENAME___ () 354 | 355 | @end 356 | 357 | @implementation ___FILEBASENAMEASIDENTIFIER___ 358 | 359 | 360 | - (instancetype)initWithFrame:(CGRect)frame { 361 | self = [super initWithFrame:frame]; 362 | if (self) { 363 | 364 | //设置view 365 | [self setupView]; 366 | } 367 | return self; 368 | } 369 | 370 | 371 | - (void)awakeFromNib { 372 | [super awakeFromNib]; 373 | 374 | //设置view 375 | [self setupView]; 376 | } 377 | 378 | #pragma mark - View 379 | - (void)setupView { 380 | 381 | } 382 | 383 | #pragma mark - Private 384 | 385 | 386 | #pragma mark - Public 387 | - (void)updateWith:(<# model #> *)<# model #> { 388 | 389 | } 390 | 391 | + (CGSize)getSize { 392 | return CGSizeMake(<#CGFloat width#>, <#CGFloat height#>); 393 | } 394 | 395 | #pragma mark - Setter 396 | 397 | 398 | #pragma mark - Getter 399 | 400 | 401 | @end 402 | 403 | ``` 404 | 405 | --------------------------------------------------------------------------------