0

Possible Duplicate:
this class is not key value coding-compliant for the key

I am facing this type of problem as when I am creating an application in XCode for iphone .

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x4d2eb20> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key singlePicker.'
*** Call stack at first throw:
Community
  • 1
  • 1
  • Without any code how can we help? Please post some code. – rohan-patel Jul 16 '12 at 10:01
  • you are creating View from XIB, but you have not set the view object in XIB. – Kapil Kumar Jul 16 '12 at 11:03
  • 1
    You're attempting to access the property `singlePicker` from a class that does not have that property. If you look at the exception traceback you'll see how the reference was made and it will help you zero in on the cause. – Hot Licks Jul 16 '12 at 11:50

1 Answers1

0

you are setting a value for a NULL Key

Edit: befor you start using the picker you need to:

in the .h file:

UIViewController<UIPickerViewDelegate,UIPickerViewDataSource>{
 NSArray *array;
}

then in the .m file:

 -(void)viewDidload{ 
  [super viewDidload];

 array = [[NSArray alloc]initWithObjects:@"Lake",@"Diana",@"Jone",@"Alice",@"Byber",@"Nuces",nil]; 

} 
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
        return [array count];
 }

 - (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
 /*  do what you want if the picker selected  */


 }


 - (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
 return [array objectAtIndex:row];

 }
Mutawe
  • 6,464
  • 3
  • 47
  • 90
  • Is there any problem in this code ?? -(void)viewDidload{ NSArray *array = [[NSArray alloc]initWithObjects:@"Lake",@"Diana",@"Jone",@"Alice",@"Byber",@"Nuces",nil]; self.pickerData = array; [array release]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; } - (void)viewDidUnload { self.singlePicker =nil; self.pickerData =nil; [super viewDidUnload]; } –  Jul 16 '12 at 10:07
  • comment the self.singlePicker=nil and self.pickerData =nil; it may be solve your problem – Tendulkar Jul 16 '12 at 10:16
  • @Tendulkar i have already done that but problem is still there this is the other remaning code .. - (void)dealloc { [singlePicker release]; [pickerData release]; [super dealloc]; } - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [pickerData count]; } - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [pickerData objectAtIndex:row]; } –  Jul 16 '12 at 10:24