0

I am getting the following errors:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: 
'[<AddListingViewController 0xe603940> setValue:forUndefinedKey:]: 
this class is not key value coding-compliant for the key listingDescription.'

by the way, listingDescription is in another class and it looks like this:

@property (nonatomic, strong) NSString *listingDescription;

Here is my AddListingViewController.h

    #import <UIKit/UIKit.h>
    #import "ListingTableViewController.h"
    #import "ListingManager.h"
    @interface AddListingViewController : UIViewController
    @property (nonatomic) ListingManager *manager;

    @end

Here is the 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

Not sure why I am getting the error. Whenever I click the bar button "add" to go to the "AddListingViewController" view controller, I get the error. Looked around but their answers didn't satisfy my needs.

Eliza Wilson
  • 1,031
  • 1
  • 13
  • 38
suntzu
  • 65
  • 3
  • 13
  • Where is the line where you set `listingDescription`? Show the code and the class instance name it is called from. – zaph Jun 29 '14 at 21:15
  • 1
    Literally every time I've had this error, it's due to something linked from interface builder. If you're using storyboard/xib, check everything on the `AddListingViewController` view and make sure none of them are attempting to link to a property with this name. – nhgrif Jun 29 '14 at 21:39
  • nhgrif > The textboxes were referencing 2 other things (previously set and forgot to remove). Silly me. Thanks everyone for answering – suntzu Jun 30 '14 at 02:20

2 Answers2

0

Not likely a related problem, but you have conflict between NSObject protocol's 'description' method and this:

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

This may lead to problems while debugging/logging out class objects.

Other than that I would track when you call 'listingDescription', or use any KVO-related mechanisms using that as a key.

deekay
  • 899
  • 6
  • 8
0

Looked around as per nhgrif's comment above. The textboxes were referencing 2 other things (previously set and forgot to remove). Silly me. Thanks everyone for answering

suntzu
  • 65
  • 3
  • 13