Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. //PersonDataViewController.h
  2.  
  3. @protocol PersonDataViewControllerDelegate;
  4. [self.delegate removePersonData:self];
  5.  
  6.  
  7. @interface PersonDataViewController : UIViewController
  8.  
  9.  
  10.  
  11. @property (weak, nonatomic) IBOutlet UITextField *nameField;
  12. @property (weak, nonatomic) IBOutlet UITextField *emailField;
  13.  
  14.  
  15. @property (nonatomic, weak) id <PersonDataViewControllerDelegate> delegate;
  16.  
  17. @property (nonatomic, strong) PersonData *currentPersonData;
  18.  
  19. - (IBAction)cancel:(id)sender;
  20. - (IBAction)save:(id)sender;
  21.  
  22. @end
  23.  
  24. @protocol AddCourseViewControllerDelegate <NSObject>;
  25. -(void)removePersonData:(PersonData *)PersonData;
  26.  
  27.  
  28.  
  29. -(void)PersonDataViewControllerDidSave;
  30. -(void)PersonDataViewControllerDidCancel(PersonData *)PersonDataToDelete;
  31.  
  32. @end
  33.  
  34.  
  35. //PersonDataViewController.m
  36.  
  37. #import "PersonDataViewController.h"
  38.  
  39. @interface PersonDataViewController ()
  40.  
  41. @end
  42.  
  43.  
  44. @implementation PersonDataViewController
  45.  
  46. @synthesize nameField;
  47.  
  48. @synthesize emailField;
  49.  
  50.  
  51. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  52. {
  53. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  54. if (self) {
  55. // Custom initialization
  56. }
  57. return self;
  58. }
  59.  
  60. - (void)viewDidLoad
  61. {
  62. [super viewDidLoad];
  63.  
  64. // Do any additional setup after loading the view.
  65. nameField.text = [self.currentPersonData PersonName];
  66.  
  67. emailField.text = [self.currentPersonData PersonEmail];
  68.  
  69.  
  70.  
  71.  
  72.  
  73. }
  74.  
  75. - (void)viewDidUnload
  76. {
  77. [self setNameField:nil];
  78.  
  79. [self setEmailField:nil];
  80.  
  81. [super viewDidUnload];
  82. // Release any retained subviews of the main view.
  83. }
  84.  
  85. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  86. {
  87. return (interfaceOrientation == UIInterfaceOrientationPortrait);
  88. }
  89.  
  90. - (IBAction)cancel:(id)sender {
  91. // dismiss and remove the object
  92.  
  93. [self.delegate PersonDataViewControllerDidCancel:[self currentPersonData]];
  94. }
  95.  
  96. - (IBAction)save:(id)sender
  97. {
  98. // dismiss and save the context
  99.  
  100.  
  101.  
  102. [self.currentPersonData setPersonName:nameField.text];
  103.  
  104. [self.currentPersonData setPersonEmail:emailField.text];
  105.  
  106.  
  107.  
  108. [self.delegate PersonDataViewControllerDidSave];
  109.  
  110.  
  111. }
  112. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement