//
// MyViewController.m
// MyHello
//
// Created by 수홍 주 on 10. 6. 23..
// Copyright 2010 All rights reserved.
//
#import "MyViewController.h"
@implementation MyViewController
@synthesize textField;
@synthesize label;
@synthesize string;
- (BOOL)textFieldShouldReturn:(UITextField *)theTextField{
[theTextField resignFirstResponder];
return YES;
}
- (IBAction) changeGreeting:(id)sender{
self.string = textField.text;
NSString *nameString = string;
if([nameString length] == 0){
nameString = @"iPhone";
}
NSString *greeting = [[NSString alloc]initWithFormat:@"안녕?%@!", nameString];
label.text = greeting;
[greeting release];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[textField release];
[label release];
[string release];
[super dealloc];
}
@end
//
// MyViewController.h
// MyHello
//
// Created by 수홍 주 on 10. 6. 23..
// Copyright 2010 All rights reserved.
//
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController <UITextFieldDelegate>{
IBOutlet UITextField *textField;
IBOutlet UILabel *label;
NSString *string;
}
@property (nonatomic, retain) UITextField *textField;
@property (nonatomic, retain) UILabel *label;
@property (nonatomic, retain) NSString *string;
- (IBAction) changeGreeting:(id)sender;
@end
|
//
// MyHelloAppDelegate.h
// MyHello
//
// Created by 수홍 주 on 10. 6. 23..
// Copyright 2010. All rights reserved.
//
#import <UIKit/UIKit.h>
@class MyViewController;
@interface MyHelloAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
MyViewController *myViewController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) MyViewController *myViewController;
@end
//
// MyHelloAppDelegate.m
// MyHello
//
// Created by 수홍 주 on 10. 6. 23..
// Copyright 2010. All rights reserved.
//
#import "MyHelloAppDelegate.h"
#import "MyViewController.h"
@implementation MyHelloAppDelegate
@synthesize window;
@synthesize myViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
MyViewController *aViewController = [[MyViewController alloc]initWithNibName:@"ControllerView" bundle:[NSBundle mainBundle]];
self.myViewController = aViewController;
[aViewController release];
UIView *controllerView = [myViewController view];
[window addSubview:controllerView];
// Override point for customization after application launch
[window makeKeyAndVisible];
return YES;
}
- (void)dealloc {
[myViewController release];
[window release];
[super dealloc];
}
@end
|
|
|