Last active
December 28, 2015 19:19
-
-
Save matteom/7549052 to your computer and use it in GitHub Desktop.
View controller to create new leads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Header file | |
@protocol PCNewLeadViewControllerDelegate <NSObject> | |
- (void)newLeadWasCreated; | |
@end | |
@interface PCNewLeadViewController : UIViewController | |
@property NSManagedObjectContext *managedObjectContext; | |
@property (weak) id<PCNewLeadViewControllerDelegate> delegate; | |
@end | |
// Implementation file | |
@interface PCNewLeadViewController () | |
@property (weak, nonatomic) IBOutlet UITextField *nameTextField; | |
@property (weak, nonatomic) IBOutlet UITextField *surnameTextField; | |
@property (weak, nonatomic) IBOutlet UITextField *companyTextField; | |
@end | |
@implementation PCNewLeadViewController | |
- (IBAction)save:(id)sender { | |
PCLead *newLead = [PCLead insertLeadInManagedObjectContext:self.managedObjectContext]; | |
newLead.name = self.nameTextField.text; | |
newLead.surname = self.surnameTextField.text; | |
newLead.company = self.companyTextField.text; | |
[self.delegate newLeadWasCreated]; | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
} | |
- (IBAction)cancel:(id)sender { | |
[self dismissViewControllerAnimated:YES completion:nil]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment