XCode 建立模板
XCode 建立模板是本文要介紹對內(nèi)容,不多說,先來看內(nèi)容。每創(chuàng)建一個文件都敲一堆東西是夠煩得,主要講述了用XBI為UIViewController子類建立XCode模板的方法,這樣再開發(fā)iPhone軟件時就不用浪費(fèi)時間了。
XCode模板存儲在 /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/ 目錄下,我們要做的就是改變創(chuàng)建UIViewController子類的模板。
該模板儲存在
- /Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/File Templates/Cocoa Touch Class/UIViewController subclass
這里有個屬性列表和2個目錄,我們感興趣的是“UIViewController subclass with XIB.pbfiletemplate”這個目錄。打開該目錄,用XCode打開 class.m 文件,
- //
- // «FILENAME»
- // «PROJECTNAME»
- //
- // Created by «FULLUSERNAME» on «DATE».
- // Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
- //«OPTIONALHEADERIMPORTLINE»@implementation «FILEBASENAMEASIDENTIFIER»
- - (id)init{ self = [super initWithNibName:
- @"«FILEBASENAMEASIDENTIFIER»"
- bundle:nil];
- // Initialize ivars not related to [self view] or XIB objects
- return self;
- }
- - (id)initWithNibName:(NSString *)nibNameOrNil
- bundle:(NSBundle *)nibBundleOrNil{
- return [self init];
- }
- - (void)viewDidLoad{
- [super viewDidLoad];
- // Init ivars that need anything from the XIB or [self view]}
- - (void)viewDidUnload{}- (void)dealloc{
- [super dealloc];
- }
- @end
把這段代碼粘到里面,以后就能省去不少麻煩,直接開發(fā)核心部分了。
小結(jié):XCode 建立模板的內(nèi)容介紹完了,希望本文對你有所幫助!
英文原文 http://weblog.bignerdranch.com/?p=155