【问题标题】:setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key adDescription.'setValue:forUndefinedKey:]:此类不符合键 adDescription 的键值编码。
【发布时间】:2015-05-03 08:03:21
【问题描述】:

我无法创建一种方法来创建数据库的广告和环境。错误是“setValue:forUndefinedKey:]: 这个类不符合键值编码的键 adDescription。'”只有在重定向我宣布注册视图时才会发生这种情况

这是观看记录:

#import "AddAdViewController.h"
#import "Ads.h"
#import "JVWebService.h"
#import "AppDelegate.h"
#import "JVUtils.h"
#import "AdsTableViewController.h"


@interface AddAdViewController () <JVWebServiceDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIPickerViewDelegate>

@property (nonatomic) BOOL show;

@property (strong, nonatomic) UITextField *currentTextField;
@end

@implementation AddAdViewController

- (void)viewDidLoad {
    [super viewDidLoad];

}


- (IBAction)addAd:(id)sender {


    if (self.adTitleField.text.length <= 0) {
        [JVUtils showMessage:@"Você precisa nos informar seu nome completo." withTitle:@"Opa!"];
    } else if (self.adPriceField.text.length <= 0) {
        [JVUtils showMessage:@"Você precisa nos informar um e-mail para contato." withTitle:@"Opa!"];
    } else if (self.adLocalField.text.length <= 0) {
        [JVUtils showMessage:@"Você precisa criar uma senha para a sua conta." withTitle:@"Opa!"];
    } else if (self.adDescriptionField.text.length <= 0) {
        [JVUtils showMessage:@"Você precisa confirmar sua senha." withTitle:@"Opa!"];
    }  else {
            Ads *newAd = [Ads new];
            newAd.title = self.adTitleField.text;
            newAd.price = self.adPriceField.text;
            newAd.local = self.adLocalField.text;
            newAd.description = self.adDescriptionField.text;


            [[JVWebService sharedService] setServiceDelegate:self];
            [[JVWebService sharedService] postAd:newAd];

        }

}


#pragma mark - Bar Button Action

- (void)cancelButtonAction {
    [self dismissViewControllerAnimated:YES completion:nil];
}

#pragma mark - JVWebService Delegate

- (void)successfulRequestDidReturnObject:(NSObject *)object {

    [JVUtils showMessage:@"Agora você tem uma conta JáVendi! Faça o login e desfrute ao máximo do aplicativo." withTitle:@"Parabéns!"];

    [[AppDelegate sharedDelegate] setCurrentUser:(User *)object];

    [self dismissViewControllerAnimated:YES completion:nil];


    AdsTableViewController *svc = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"LoginViewController"];

    [self.navigationController presentViewController:[[UINavigationController alloc] initWithRootViewController:svc]
                                            animated:YES
                                          completion:nil];




}

- (void)requestDidFailWithError:(NSError *)error {

    [JVUtils showMessage:error.localizedDescription withTitle:@"Erro"];
}




@end

【问题讨论】:

    标签: objective-c iphone ios8


    【解决方案1】:

    此错误表示您试图在没有 adDescription 属性的对象上设置名为“adDescription”的属性。我没有看到你直接引用这个变量,所以它可能是在你的一个设置器中设置的,特别是在你制作广告的地方,或者这一行

    [[AppDelegate sharedDelegate] setCurrentUser:(User *)object];
    

    【讨论】:

      猜你喜欢
      • 2013-12-03
      • 2017-09-09
      • 1970-01-01
      • 2014-01-12
      • 1970-01-01
      • 2017-10-15
      • 1970-01-01
      相关资源
      最近更新 更多