我收到以下错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<AddListingViewController 0xe603940> setValue:forUndefinedKey:]:
this class is not key value coding-compliant for the key listingDescription.'
顺便说一句,listingDescription 在另一个类中,它看起来像这样:
@property (nonatomic, strong) NSString *listingDescription;
这是我的 AddListingViewController.h
#import <UIKit/UIKit.h>
#import "ListingTableViewController.h"
#import "ListingManager.h"
@interface AddListingViewController : UIViewController
@property (nonatomic) ListingManager *manager;
@end
这是 AddListingViewController.m
#import "AddListingViewController.h"
@interface AddListingViewController ()
@property (weak, nonatomic) IBOutlet UITextField *title;
@property (weak, nonatomic) IBOutlet UITextView *description;
@property (weak, nonatomic) IBOutlet UITextField *price;
@end
@implementation AddListingViewController
- (instancetype)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.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//cancel posting on tap
- (IBAction)cancelListing:(UIBarButtonItem *)sender {
NSLog(@"cancel tapped thpugh");
[self dismissViewControllerAnimated:YES completion:nil];
}
//add item on tap
- (IBAction)addListing:(UIBarButtonItem *)sender {
NSLog(@"Add button tapped");
}
@end
不知道为什么我收到错误。每当我单击条形按钮“添加”以转到“AddListingViewController”视图控制器时,我都会收到错误消息。环顾四周,但他们的答案并不能满足我的需求。