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 8992465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:57:40+00:00 2026-06-15T22:57:40+00:00

I am new in programming.I have an basic doubt of inheritance.I have a UITableView

  • 0

I am new in programming.I have an basic doubt of inheritance.I have a UITableView in ViewController and when I select first row of Tableview.It take me to the Picker page in which only I have to select value from UIPickerViewthats fine now I have to NSLOG selected value of picker in a ViewController in button.this is small problem I am facing.

VIewController.m

- (void)viewDidLoad
 {
 [super viewDidLoad];

tableview =[[UITableView alloc]initWithFrame:CGRectMake(0,0,([UIScreen mainScreen].bounds.size.width),([UIScreen mainScreen].bounds.size.height/2)) style:UITableViewStyleGrouped];
tableview.delegate=self;
tableview.dataSource=self;
[self.view addSubview:tableview];




button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(pressed) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"START " forState:UIControlStateNormal];
button.frame = CGRectMake(62, 250, 196, 37);
[self.view addSubview:button];



thearray= [[NSArray alloc]initWithObjects:@"A",@"B ",@"C",@"D",@"E" ,nil];



 [super viewDidUnload]; 
}

 -(void)pressed{
  // nslog value..i need here the picker value
   }

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}



 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{


return 5;
}



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{


if(indexPath.row==0){

 Picker1 *pick= [[Picker1 alloc] init];


    [self navigationController] pushViewController:pick animated:YES]      
}


 }




 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS IndexPath *)indexPath  
{  
static NSString *CellIdentifier = @"Cell";  


 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
 if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}


cell.textLabel.text=[thearray objectAtIndex:indexPath.row];

 return cell;
}

Picker.m

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

return 1;

}

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

return [list count];

}

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

return [list objectAtIndex:row];

}


- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {

// update label text to show selected option

string=[NSString stringWithFormat:@"%@",[list objectAtIndex:row]];

label.text=string;


[self dismissModalViewControllerAnimated:YES];



 }


- (void)viewDidLoad
{
[super viewDidLoad];

list =[[NSMutableArray alloc]init];
[list addObject:@"A"];
[list addObject:@"B"];
    [list addObject:@"C"];



}
  • 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-15T22:57:41+00:00Added an answer on June 15, 2026 at 10:57 pm

    You can use delegates

    in picker.m,above @interface section do this

    @protocol pickerDelegate <NSObject>
    

    -(void)didFinishPicking:(NSString *)pickedStr;

    @end
    

    make property of this protocol

    @property(nonatomic,weak)id<pickerDelegate>delegate
    

    and in – (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component method, do this

    string=[NSString stringWithFormat:@"%@",[list objectAtIndex:row]];
    
    
    
    [self.delegate didFinsihPicking:string];
    

    now in viewcontroller.h, in the method

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    
    
     Picker1 *pick= [[Picker1 alloc] init];
    
    [pick setDelegate : self];
    

    and implement the dlegate method in viewcontroler.h

        -(void)didFinishPicking:(NSString *)pickedStr
    {
    [self setStr:pickedStr]
    }
    

    where str is the string variable you need to declare in viewcontroller.h and print this string on button click event

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

Sidebar

Related Questions

I'm new to programming, I have some basic python programming from college, I am
I am new to VSTO programming. I have created a basic addin for Outlook
I'm fairly new to iOS programming, but have a basic understanding of it. I
I'm new to concurrent programming so be nice. I have a basic sequential program
I’m new to visual basic.net . I have experience in C++ programming, but never
I am new to Qt Programming, but I have basic on C++. I want
Im new to Database programming and I have a very basic question: In my
I am new to programming and Python. I have a very basic python script
I'm new to functional programming. I have a basic question. I'm using the Hugs
I am new to Android programming and have a basic question. I have created

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.