I am attempting to pass data back from one Table View Controller to the one before it. Here is the code I have written to accomplish it: NPViewController.h (The second view passing data back):
@class NPViewController;
@protocol NPViewControllerDelegate <NSObject>
-(void) passItemBack: (NPViewController *) controller didFinishWithItem: (NSString *) string;
@end
@interface NPViewController : UITableViewController <UITextFieldDelegate>
@property (weak, nonatomic) id<NPViewControllerDelegate> delagate;
- (IBAction)createNewProject:(id)sender; //a bar button item that sends data on click
@end
NPViewController.m:
//barButton item IBAction
- (IBAction)createNewProject:(id)sender {
[self.delagate passItemBack:self didFinishWithItem:@"Test"];
[self dismissViewControllerAnimated:YES completion:nil];
}
InternalTabViewController.h //the first view to recieve data
#import <UIKit/UIKit.h>
#import "NPViewController.h"
@interface InternalTabViewController : UITableViewController <NPViewControllerDelegate>
@property (weak, nonatomic) NSString * projectName;
@property (weak, nonatomic) NSString * projectWorth;
@end
InternalTabViewController.m
@synthesize projectName, projectWorth;
//in ViewDidLoad
NPViewController *NPVC = [self.storyboard instantiateViewControllerWithIdentifier:@"NPViewController"];
NPVC.delagate = self;
//implementation of protocol function
-(void)passItemBack:(NPViewController *)controller didFinishWithItem:(NSString *)string
{
self.projectName = string;
}
The program cannot get past the first view controller (unrelated to these two) and throws the error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key createNewProject.'
I'm just trying to pass two strings back from one screen to another. How do I resolve this?