프로가 되자.

post search result

Objective-C template와 관련된 글 1개를 찾았습니다.

  1. 2009/08/10 Xcode에서 자동으로 생성되는 template 수정하기

Xcode에서 자동으로 생성되는 template 수정하기

Xcode에서 객체를 새로 생성하면 다음과 같이 자동으로 code가 입력되어 있는 것을 보실 수 있습니다.

#import "TestClass.h"

@implementation TestClass

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}


- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (void)dealloc {
    [super dealloc];
}

@end


개인적으로 괄호 여는 스타일, 들여쓰기가 default로 공백이라는 점 등등 마음에 안드는 점이 한두개가 아닌데요, 아래의 경로에서 이러한 자동 생성되는 코드를 수정할 수 있습니다.

/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/File Templates


안에 보시면..

사용자 삽입 이미지

위의 그림에서와 같이 iPhone OS의 Cocoa Touch Class, Code Signing등의 디렉토리를 보실 수 있습니다.
여기서는 Cocoa Touch Class의 Objective-C class에 있는 UIView 클래스의 기본 코드를 수정 하도록 하겠습니다.

우선

/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/File Templates/Cocoa Touch Class/Objective-C class/UIView subclass.pbfiletemplate


로 이동한 뒤, class.h와 class.m 파일을 수정합니다. (만일의 사태에 대비하여 수정 전 백업 해두세요)
기본적으로 아래와 같이 되어 있는 코드를..

//
//  «FILENAME»
//  «PROJECTNAME»
//
//  Created by «FULLUSERNAME» on «DATE».
//  Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
//
«OPTIONALHEADERIMPORTLINE»
@implementation «FILEBASENAMEASIDENTIFIER»

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        // Initialization code
    }
    return self;
}


- (void)drawRect:(CGRect)rect {
    // Drawing code
}


- (void)dealloc {
    [super dealloc];
}

@end


다음과 같이 변경하였습니다

//
//  «FILENAME»
//  «PROJECTNAME»
//
//  Created by «FULLUSERNAME» on «DATE».
//  Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved.
//
«OPTIONALHEADERIMPORTLINE»
@implementation «FILEBASENAMEASIDENTIFIER»

- (id)initWithFrame:(CGRect)frame
{
        if (self = [super initWithFrame:frame])
        {
                // Initialization code
        }
        return self;
}

- (void)drawRect:(CGRect)rect
{
        // Drawing code
}

- (void)dealloc
{
        [super dealloc];
}

@end


변경하고 나서 UIView 클래스를 생성하면 깔끔한 코드가 나옵니다.
나머지 클래스들도 동일한 방법으로 수정하시면 됩니다.

크리에이티브 커먼즈 라이센스
Creative Commons License
2009/08/10 13:46 2009/08/10 13:46

top

About this post

이 글에는 아직 트랙백이 없고, 아직 댓글이 없고, , 태그가 달려있으며,
2009/08/10 13:46에 작성되었습니다.

◀ recent : [1] : previous ▶

blog information

프로가 되자.
BLOG main image
빗소리를 먹는 사람.
RSS 2.0Tattertools
최근 글 최근 댓글 최근 트랙백
태그 구름사이트 링크