- 2012/05/15 23:01
- upthere9.egloos.com/2866073
- 덧글수 : 0
- 2012/04/14 14:48
- upthere9.egloos.com/2858598
- 덧글수 : 0
application.applicationState로 홈버튼 VS 대기시간 확인.
[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:...]
로 최대 10분간 background에서 작업 가능
- 2012/04/14 14:27
- upthere9.egloos.com/2858592
- 덧글수 : 0
SecondViewController.h
#import <UIKit/UIKit.h>
@protocol SecondViewControllerDelegate;
@interface SecondViewController : UIViewController {
UITextField *textField;
id<SecondViewControllerDelegate> delegate;
}
@property (nonatomic,assign) id<SecondViewControllerDelegate> delegate;
@end
@protocol SecondViewControllerDelegate<NSObject>;
@required
-(void) secondViewControllerInputDidEnd:(NSString *)text;
@end
그 다음에 SecondViewController.m파일을 봅시다
//property로 지정한 delegate를 다른 오브젝트에서 써줘야 하니 @synthesize로 접근가능하게 하는걸 잊지 맙시다.
@synthesize delegate;
- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Second ViewController";
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"Done"style:UIBarButtonSystemItemSave target:self action:@selector(done)];
self.navigationItem.rightBarButtonItem = doneButton;
[doneButton release];
textField = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 300, 25)];
textField.borderStyle = UITextBorderStyleRoundedRect;
[self.view addSubview:textField];
}
-(void) done{
[self.delegate secondViewControllerInputDidEnd:textField.text];
[self.navigationController popViewControllerAnimated:YES];
}
원글
- 2012/04/14 14:05
- upthere9.egloos.com/2858584
- 덧글수 : 0
카테고리
기존 class에 메서드만 추가하는 것.
기존 class instance변수에 접근할 수 있지만, 새 instance 변수 추가는 안됨.
예 )
@interface ClassName (CategoryName)
- Method
- Method
@end
@implementation ClassName (CategoryName)
프로토콜
클래스 사이에 공유되는 메서드 목록.
프로토콜을 따른다면, 프로토콜에 들어있는 메서드를 모두 구현해 주어야함.
objbect가 프로토콜을 따른다고 다음처럼 선언할 수 있음.
id <ProtocolName> objectName
예 )
@protocol ProtocolName
- Method
- Mehtod
@optional
- Mehtod
@required
- Method
@end
@interface ClassName: ParentClassName <ProtocolName1, ProtocolName2>
@end





최근 덧글