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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:01:21+00:00 2026-05-29T22:01:21+00:00

I am trying to get a number from an array and store it in

  • 0

I am trying to get a number from an array and store it in a button in UITableview cell. When I tap the button, I should be able to get the number. Whats the right way to get the information from the sender in the button click event

This is what I tried.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil )
{
    UIButton *button = [[[UIButton alloc]init]autorelease];
    CGRect frame = CGRectMake(180, 10, 33, 33);
    button.frame = frame;
    button.tag = 1001;

    UIImage *image = [[[UIImage alloc]init]autorelease];
    image = [UIImage imageNamed:@"icon.png"];
    [button setBackgroundImage:image forState:UIControlStateNormal];

    [button addTarget:self action:@selector(onIconTapped)  forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor clearColor];
    [button setHidden:YES];
    cell.accessoryView = button;  

}

int myContactID = contact.contactID;
NSLog(@"My No.  %d", myContactID);
NSNumber *mySelectedNumber = [NSNumber numberWithInt:myContactID];

UIButton *myButton = (UIButton *)[cell.accessoryView viewWithTag:1001];
for(int i = 0; i< [myContactsArray count]; i++){
    if([[[myContactsArray objectAtIndex:i]valueForKey:@"RecordID"] isEqualToNumber:mySelectedNumber]){

        [myButton setHidden:NO];
        NSString *myString;
        myString = [[myContactsArray objectAtIndex:i]valueForKey:@"MYNumber"];
        [myButton setTitle:myString forState:UIControlStateNormal];
        myButton.titleLabel.font = [UIFont systemFontOfSize:0];
        NSLog(@"my number %@", myString);
        NSLog(@"Button tag %@", myButton.currentTitle);
        break;
    }
    else{
       [myButton setHidden:YES];
    }
}
}



-(void)onIconTapped:(id)sender{
}
  • 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-29T22:01:24+00:00Added an answer on May 29, 2026 at 10:01 pm
    -(void)onIconTapped:(id)sender{
    
      if (sender.tag == 1001){
      NSString *title = sender.currentTitle;
    
      NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease];
      [formatter setNumberStyle:NSNumberFormatterDecimalStyle];
    
      NSNumber *titleNumber = [numberFormatter numberFromString:title]; 
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get my first button to update a display number in
I'm trying to find a way to get the total number of child nodes
I'm trying to get a value from an array used in the Joomla Plugin
I'm trying to get this C++ code to input a series of numbers from
I am trying to write a regex to get the numbers from strings like
In a PowerShell script I am trying to get the number of page faults
I've struggled with this all day, I am trying to get a random number
I'm trying to get the integer value of The number selected of the item.
I'm trying to do project Euler number 219 but am failing to get a
I'm trying to parse phone number with regex. Exactly I want to get a

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.