次のエラーが表示されます。
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」ビューコントローラーに移動すると、エラーが発生します。周りを見回しましたが、彼らの答えは私のニーズを満たしていませんでした.