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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:25:59+00:00 2026-06-05T19:25:59+00:00

Using storyboard, I have a table view controller containing multiple dynamic prototype cells. One

  • 0

Using storyboard, I have a table view controller containing multiple dynamic prototype cells. One of the cells is a custom dynamic prototype cell (for which I created a subclass) containing a label and a switch. I have the action for the switch wired to an action method (say switchChanged:) in the view controller. In cellForRowAtIndexPath, I configure and return the cell appropriate for the specified index. So far so good.

The problem: my application has multiple instances of these custom cells, so how do I differentiate which switch has changed? One thought is that in the view controller I can create a member switch for each cell and link them to a specific cell switch when cellForRowAtIndexPath is called for the first time. Then I can use these member switches to compare with the switch that is passed into switchChanged:.

I know that I can try it and get an immediate answer, but I was hoping for a discussion of how other developers do what I am trying to do. Is this the best/worst/ok approach and what are practical alternatives?

Regards,

–John

  • 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-05T19:26:01+00:00Added an answer on June 5, 2026 at 7:26 pm

    I had this situation once (not with switches, but I believe it applies just the same). I’ve managed to get around it by subclassing the object class and adding the required properties/methods inside the subclass.

    When calling the action, your sender will be the subclass, and you can access your added code there.

    I don’t know if it is the case, but if you’re only trying to change a value, you should use bind the switch value to the property when creating the object. It will not even need an IBAction to call.

    EDIT: Example:

    @interface MySwitch : UISwitch
    @property (nonatomic, assign) NSUInteger someProperty;
    @end
    

    Then, every time you create a cell, you can set “someProperty” to anything you want.

    -(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath {
      // yada yada yada...
      UITableViewCell *cell;
      // yada yada yada...
    
      [cell.myLinkedSwitch  setSomeProperty:indexPath.row];
      return(cell);
    }
    

    Unless you’re not creating your cells using the tableView:cellForRowAtIndexPath: method. Then you probably should use bindings to get your value to the right place.

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

Sidebar

Related Questions

I am building an app using storyboard. I have added a table view to
I was using storyboard segue to push from one view controller A to view
I have one project using storyboard. I have one UIView and I put some
I am using a storyboard and I have added iAd banner to my view.
Im using Storyboard for most screens in my iPhone app. However, I have one
I have a navigation view controller which navigates between some tableviews and I've just
I'm using a StoryBoard which contains various ViewControllers and a TableViewController, one in particular
In iOS5 using storyboard feature I want to create a custom container which will
I am using Storyboard with a Navigation Controller and prepareforsegue. I have two UITableViews.
I have a table in which in one of the column I would be

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.