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

  • Home
  • SEARCH
  • 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 6549457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:05:44+00:00 2026-05-25T12:05:44+00:00

I think this is probably a very rudimentary question, but after a few hours

  • 0

I think this is probably a very rudimentary question, but after a few hours of searching, I can find some people with my issue, but none of the solutions I found work.

I am just getting my feet wet with iPhone development, though I have writing Android and Blackberry apps, so the Objective-C is a bit of a switch from Java.

First of all, when I try to open the screen with a UIPickerView on it, I get this error message:

[UIViewController numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0x4b4e0d0
2011-09-09 15:57:19.619 TabBar[4945:207] * Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[UIViewController numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0x4b4e0d0’

Here is my header file:

#import <UIKit/UIKit.h>

@interface ThirdViewController : UIViewController <UIPickerViewDelegate,        UIPickerViewDataSource>{
UILabel *setUnits;
UIPickerView *pickerView;
NSMutableArray *pickItems;
}
@property (retain, nonatomic) UIPickerView *pickerView;
@property (retain, nonatomic) NSMutableArray *pickItems;

@end

And here is my implementation file:

#import "ThirdViewController.h"

@implementation ThirdViewController

@synthesize pickerView;
@synthesize pickItems;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
    // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
}
*/

// Implement viewDidLoad to do additional setup after loading the view, typically from a     nib.
- (void)viewDidLoad {
    [super viewDidLoad];

    pickItems = [[NSMutableArray alloc] init];
    [pickItems addObject:@"Pounds"];
    [pickItems addObject:@"Kilograms"];
}

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {

    return 1; //give components here
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:    (NSInteger)component {

     return [pickItems count];   //give rows here
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {   
    return [pickItems objectAtIndex:row];  // give titles 
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
    //Do the step here
}

- (void)dealloc {
     [super dealloc];
}
@end

I have checked, and both the delegate and dataSource are connected to the file’s Owner. Am I missing something?

Thanks.

  • 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-05-25T12:05:44+00:00Added an answer on May 25, 2026 at 12:05 pm

    I suspect that in the Interface Builder / xib file you need to change your UIViewController class to the ThirdViewController class. In any case the error message is telling you that your are sending the message to a UIViewController instance and not an instance of the subclass you have created. Common (but not the only) cause is IB / xib settings – but you make the error programmatically too. (With IB / xib it is easy to do, even if you’ve been using iOS for a while.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably a very common question, but I was unable to find an
I think this is probably a very simple but I can get my head
Ok, I think this is probably an easy question but for the life of
I think this could be a very easy question for you. But I have
All, This question probably has a very simple answer - something I'm overlooking. But
This is probably a very simple and stupid question to ask, but I have
Hi you probably think this is a dumb question but I am trying to
This is probably a very trivial question, but.. Assuming we have a variable 'a'
This is probably a very easy question, but I never really did web... so
This probably is a very noobish question, but I want to make sure my

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.