0

次のエラーが表示されます。

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

4

2 に答える 2

0

上記のnhgrifのコメントに従って周りを見回しました。テキストボックスは他の 2 つのものを参照していました (以前に設定され、削除するのを忘れていました)。愚かな私。みんな答えてくれてありがとう

于 2014-06-30T13:43:02.117 に答える
0

おそらく関連する問題ではありませんが、NSObject プロトコルの「説明」メソッドとこれの間に競合があります。

@property (weak, nonatomic) IBOutlet UITextView *description;

これにより、クラス オブジェクトのデバッグ/ログアウト中に問題が発生する可能性があります。

それ以外では、いつ「listingDescription」を呼び出すか、それをキーとして使用して KVO 関連のメカニズムを使用するかを追跡します。

于 2014-06-29T23:23:52.527 に答える