2015-03-02 109 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]; 
相關問題