Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8504393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:01:05+00:00 2026-06-11T02:01:05+00:00

I have a uipickerview which i want to populate with data from my sqlite

  • 0

I have a uipickerview which i want to populate with data from my sqlite database.

I have got access to the data via a mutable array via the appdelegate but when i use that as the data source it is crashing the app when used as the uipicker titleforrow section.

The count from the array is correct it just will not display any data!

Here is my header file:

@class OBMessage;

@interface LocationViewController : UIViewController <UITableViewDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDataSource, UIActionSheetDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMailComposeViewControllerDelegate, MFMessageComposeViewControllerDelegate> {
        UITableViewCell *cell1;
        UITableViewCell *cell2;
        UITableViewCell *cell3;
        UITableViewCell *cell4;
        UITableViewCell *cell5;
        UITableViewCell *cell6;
        UITableViewCell *cell7;
    UITableViewCell *cell8;
        IBOutlet UILabel *addressLabel;
        MKPlacemark *placemark;
        IBOutlet UILabel *lLat;
        IBOutlet UILabel *lLong;
        IBOutlet UILabel *lHAcc;
        IBOutlet UILabel *lAlt;
        IBOutlet UILabel *lVAcc;
        IBOutlet UILabel *lDate;
        UIPickerView *singlePicker;
        NSArray *pickerData;
        NSString *pickedInfo;
        DadsTaxiV2AppDelegate *appDelegate;
        NSMutableArray *myarray;



}
@property (nonatomic, retain) IBOutlet UITableViewCell *cell1;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell2;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell3;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell4;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell5;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell6;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell7;
@property (nonatomic, retain) IBOutlet UITableViewCell *cell8;
@property (nonatomic, retain) IBOutlet UILabel *addressLabel;
@property (nonatomic, retain) IBOutlet UILabel *lLat;
@property (nonatomic, retain) IBOutlet UILabel *lLong;
@property (nonatomic, retain) IBOutlet UILabel *lHAcc;
@property (nonatomic, retain) IBOutlet UILabel *lAlt;
@property (nonatomic, retain) IBOutlet UILabel *lVAcc;
@property (nonatomic, retain) IBOutlet UILabel *lDate;
@property (nonatomic, retain) IBOutlet UIPickerView *singlePicker;
@property (nonatomic, retain) NSArray *pickerData;
@property (nonatomic, retain) NSString *pickedInfo;
@property (nonatomic, retain) NSMutableArray *myarray;


@property (nonatomic, retain) MKPlacemark *placemark;

-(IBAction)popupCameraSheet:(id)sender;
-(IBAction)popupMessageSheet:(id)sender;
-(void)showPicker;


@end

Here is bits of my m file:

- (void)viewDidLoad {


      [super viewDidLoad];

    appDelegate = (DadsTaxiV2AppDelegate *)[[UIApplication sharedApplication] delegate];

    self.myarray = appDelegate.messageArray;




}


-(void)showPicker
{
    UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"Select a Office Buddy Message to Include:"
                                                      delegate:self
                                             cancelButtonTitle:@"Select" destructiveButtonTitle:@"Cancel"
                                             otherButtonTitles:nil];
    menu.tag = 4;
    menu.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    singlePicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 185, 0, 0)];
    singlePicker.delegate=self;
    singlePicker.showsSelectionIndicator = YES;

    [singlePicker selectedRowInComponent:0];
    [singlePicker reloadComponent:0];

    [menu addSubview:singlePicker];
    [menu showInView:self.view];
    [menu setBounds:CGRectMake(0, 0, 320, 700)];

    [singlePicker release];
    [menu release];

    //NSInteger row = [singlePicker selectedRowInComponent:1];
    //NSString *selected = [pickerData objectAtIndex:row];

    //infoLabel.text = selected;



}

#pragma mark Picker Data Source Methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
    return 1;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    //NSLog(@"[pickerData count]=%d",[pickerData count]);
    //return [pickerData count];

    NSLog(@"[messagearray count]=%d",[self.myarray count]);
    //return [self.pickerData count];
    return [self.myarray count];

}

#pragma mark Picker Delegate Methods
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
    NSLog(@"[pickerData objectAtIndex:row]=%@",[self.myarray objectAtIndex:row]);
    //return [self.pickerData objectAtIndex:row];
    return [self.myarray objectAtIndex:row];
}

Sorry forgot the crash log:

didSelectViewController:<LocationViewController: 0x9b7de90>
2012-09-07 20:43:07.142 OfficeBuddy[7300:c07] [messagearray count]=13
2012-09-07 20:43:07.142 OfficeBuddy[7300:c07] [messagearray count]=13
2012-09-07 20:43:07.142 OfficeBuddy[7300:c07] [pickerData objectAtIndex:row]=<OBMessage: 0x9a74ae0>
2012-09-07 20:43:07.143 OfficeBuddy[7300:c07] -[OBMessage isEqualToString:]: unrecognized selector sent to instance 0x9a74ae0
2012-09-07 20:43:07.144 OfficeBuddy[7300:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[OBMessage isEqualToString:]: unrecognized selector sent to instance 0x9a74ae0'
*** First throw call stack:
(0x1759022 0x1a5ecd6 0x175acbd 0x16bfed0 0x16bfcb2 0x8ed0ff 0xbcf17a 0x7a8bc0 0x847c54 0x8483ce 0x833cbd 0x83271a 0x83c220 0xbcf6bb 0x7a77ec 0x7a84f9 0x8ca1 0xcc71 0x83e5c5 0x83e7fa 0x47585d 0x172d936 0x172d3d7 0x1690790 0x168fd84 0x168fc9b 0x22847d8 0x228488a 0x7ad626 0x2f5d 0x2ed5)
terminate called throwing an exception(lldb) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:01:07+00:00Added an answer on June 11, 2026 at 2:01 am

    By your crash log, it seems that the data you are populating your array with is an instance of the OBMessage class. When returning from the datasource method:

    - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
    

    Make sure you are returning a string. So, if your array is populated by instances of the OBMessage, use a property from that class that represents what you want to present on your picker. For example, if OBMessage has a property called messageStringRepresentation, you would return:

    return [[self.myarray objectAtIndex:row] messageStringRepresentation];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a uipickerview, which has a dictionary as a datasource. I want to
I have a UIPickerView which works correctly, now I want to add a button
I have three labels, which I want to fill with selected row from pickerview.
I have a UIPickerView which will be loaded with two different data sets based
I have a UIPickerView as subview in a UITableViewController, which I want to slide
I have got UIPickerview in my application working fine. I want to change the
I have a UIPickerView in my app in which the 'tick' sound when moving
I'm trying to have a UIPickerView slide from the bottom of the screen (over
I have 3 row data in UIPickerView that is timeHour, timeMinute, timeSecond. How to
I have been having trouble pulling up a custom UIPickerView from the textfield's inputview

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.