Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PersonDataViewController.h
- @protocol PersonDataViewControllerDelegate;
- [self.delegate removePersonData:self];
- @interface PersonDataViewController : UIViewController
- @property (weak, nonatomic) IBOutlet UITextField *nameField;
- @property (weak, nonatomic) IBOutlet UITextField *emailField;
- @property (nonatomic, weak) id <PersonDataViewControllerDelegate> delegate;
- @property (nonatomic, strong) PersonData *currentPersonData;
- - (IBAction)cancel:(id)sender;
- - (IBAction)save:(id)sender;
- @end
- @protocol AddCourseViewControllerDelegate <NSObject>;
- -(void)removePersonData:(PersonData *)PersonData;
- -(void)PersonDataViewControllerDidSave;
- -(void)PersonDataViewControllerDidCancel(PersonData *)PersonDataToDelete;
- @end
- //PersonDataViewController.m
- #import "PersonDataViewController.h"
- @interface PersonDataViewController ()
- @end
- @implementation PersonDataViewController
- @synthesize nameField;
- @synthesize emailField;
- - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
- {
- self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
- if (self) {
- // Custom initialization
- }
- return self;
- }
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- nameField.text = [self.currentPersonData PersonName];
- emailField.text = [self.currentPersonData PersonEmail];
- }
- - (void)viewDidUnload
- {
- [self setNameField:nil];
- [self setEmailField:nil];
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- }
- - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- {
- return (interfaceOrientation == UIInterfaceOrientationPortrait);
- }
- - (IBAction)cancel:(id)sender {
- // dismiss and remove the object
- [self.delegate PersonDataViewControllerDidCancel:[self currentPersonData]];
- }
- - (IBAction)save:(id)sender
- {
- // dismiss and save the context
- [self.currentPersonData setPersonName:nameField.text];
- [self.currentPersonData setPersonEmail:emailField.text];
- [self.delegate PersonDataViewControllerDidSave];
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement