2015-03-02 39 views
0

我不能创建一个方法来创建广告和envialo到数据库。错误是“setValue:forUndefinedKey:]:这个类别不是关键字adDescription的关键字编码标准。'”这个,只有当重定向我宣布注册视图时才会发生。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 

回答

0

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

[[AppDelegate sharedDelegate] setCurrentUser:(User *)object]; 
相关问题