제4장. Objective c 하편

2012. 3. 29. 15:03Language/iPhone

반응형

1. iPhone개발을 해보자!!

- viewContraller

      1) .h      : view의 컨트롤을 위한 코딩을 해준다 물론 해더니깐 선언만

      2) .m   : 헤더에 대한 구현부

      3) xib  : 여기에서 마치 비주얼베이직이나 MFC에서의 컴포넌트들을 마우스로 끌어다가 만들어주며

                   연결시켜주는 부분이다.

                   IBOutlet과 IBAction 이 있다.


헤더 파일 소스


#import <UIKit/UIKit.h>


@interface ViewController : UIViewController

{

    UILabel *note;

    UITextField *display;    

}


@property (retain, nonatomic)IBOutlet UILabel *note;

@property (retain, nonatomic) IBOutlet UITextField *display;


-(IBAction)click1:(id)sender;


@end



구현파일 소스


#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController

@synthesize note, display;

-(void) click1:(id)sender

{

    NSString *string;

    string = [NSString stringWithFormat:@"입력된 문자열 : %@",

              display.text];

    [note setText:string];

    

}


- (void)viewDidLoad

{

    [super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}


- (void)viewDidUnload

{

    [super viewDidUnload];

    // Release any retained subviews of the main view.

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

}


@end


XIB에서는 File's Owner와 연결을 시켜준다.




반응형

'Language > iPhone' 카테고리의 다른 글

5일차 : Objective C 오후  (0) 2012.03.30
5일차 : Objective-C 오전  (0) 2012.03.30
제 4장. Objective C  (6) 2012.03.29
제3장. Objective C[오전+오후]  (0) 2012.03.28
제2장. Objective C (하편)  (0) 2012.03.27