3

I'm totally stuck with the UIPickerView. I keep getting the error :

GDB: received signal: "SIGABRT".

2011-07-14 13:35:19.132 MeldStad[677:207] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0xaac34c0'

I've read some solution on internet but none of them worked for me.. I've also tried more than 1 PickerView tutorial. Don't know what to do know.

Here is the source of the picker methods:

- (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];
}
Th3noon
  • 47
  • 1
  • 7
  • How have you set the delegate and where have you added these methods? – Deepak Danduprolu Jul 14 '11 at 12:06
  • ok i think the connections are good now. I followed this tutorial for connections (step 6). http://www.roseindia.net/tutorial/iphone/examples/UIPickerView/UIPickerViewExample.html The error is gone, but when i try to retrieve the selected item by clicking on a button, i don't get anything back. NSInteger row = [singlePicker selectedRowInComponent:0]; NSString *selected = [pickerData objectAtIndex:row]; NSLog(@"test:", selected); – Th3noon Jul 14 '11 at 12:22
  • `singlePicker` must be `nil` i.e. not connected in IB. Check that. – Deepak Danduprolu Jul 14 '11 at 12:27
  • thnx alot for your help, it works now :) – Th3noon Jul 14 '11 at 12:29

1 Answers1

7

The error is saying that you setup your UIPicker delegate in the IB to the UIView where you don't have UIPickerDelegate methods

@interface YourViewController : UIViewController <UIPickerViewDelegate> 

Or you assigned your delegates to a wrong file. Check IB connection settings. Your datasource and delegate should be set to FilesOwner

Cyprian
  • 9,423
  • 4
  • 39
  • 73
  • ok i think the connections are good now. I followed this tutorial for connections (step 6).http://www.roseindia.net/tutorial/iphone/examples/UIPickerView/UIPickerViewExample.html The error is gone, but when i try to retrieve the selected item by clicking on a button, i don't get anything back. NSInteger row = [singlePicker selectedRowInComponent:0]; NSString *selected = [pickerData objectAtIndex:row]; NSLog(@"test:", selected); – Th3noon Jul 14 '11 at 12:27