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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:04:43+00:00 2026-06-10T00:04:43+00:00

The prequel of this problem is here . I am trying to create and

  • 0

The prequel of this problem is here.

I am trying to create and set a custom delegate and datasource to my programmatically created UITableView. I’ve googled around, but couldn’t find any clear solution for my problem.

Meanwhile, I’ve created a new class that conforms to UITableViewDelegate,UITableViewDataSource
protocols. In this class:

tableView numberOfRowsInSection: 20
tableView cellForRowAtIndexPath: cell.textLabel.text=@”Nominals”;

Class that contains UIViews:

Method that creates UITableView:

-(IBAction)segmentValueChaged:(id)sender
{
if(self.segment.selectedSegmentIndex==0)
{
    [self.coinageView removeFromSuperview];
    [self.view addSubview:nominalsView];
    [self populateNominals:self.subCountryID];
}
else 
{
    [self.nominalsView removeFromSuperview];
    [self.view addSubview:coinageView];
    [self populateCoinages:self.subCountryID];
}
}

-(void)populateNominals:(int)subCountryID
{
NominalsTableViewDelegate *del=[[NominalsTableViewDelegate alloc]init];
UITableView *nominalsTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320, 372) style:UITableViewStylePlain];
[nominalsTableView setDelegate:del];
[nominalsTableView setDataSource:del];
[self.nominalsView addSubview:nominalsTableView];
[nominalsTableView reloadData];
}

Finally, I’m getting EXC_BAD_ACCESS.
The evil is in [nominalsTableView setDelegate:del]; [nominalsTableView setDataSource:del]; rows. What’s wrong with them.

Help is much appreciated. Thanks in advance.

  • 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-10T00:04:44+00:00Added an answer on June 10, 2026 at 12:04 am

    I am not sure if you are adding a new UITableView to your current view or not, but I will assume you are doing so.

    If you have a class that conforms to the UITableViewDelegate. But when i needed to create a UITableView programmatically, I create a new UITableView class (with the .h and .m) then make a MutableArray and exposing it as a property to the parent view so it can set the data source.

    From there, you can create an instance of the class along with the datasource (which you exposed from the child object). Finally, you then add the view onto your current view. This method you dont need to set the delegate because your child class conforms to the tableview delegate protocol.

    If you are just modifying the data inside the current tableview then, you use a NSMutableArray and then change the data in it. After then do a

          [self.tableView reloadData];
    

    Hope this helps!

    EDITED

    I might have misunderstood your question, what you (most likely) need to do is create a property of the delegate class then create an instance of your delgate class and assign it to the property.

    Then do a

          [myTableView setDelegate:self.myProperty];
          [myTableView setDatasource:self.myProperty];
    

    This, I believe, would solve you bad access problem.

    EDITED AGAIN

    Create a property inside your .h of the tableview class as such:

        @property (nonatomic, retain) NominalsTableViewDelegate *myDelegate;
    

    From there then inside your .m file, you do something similar to this:

    NominalsTableViewDelegate* delegateClass = [[NominalsTableViewDelegate alloc] init];
    [self setMyDelegate:delegateClass];
    [delegateClass release];
    

    Then you can set your tableview datasource as such:

    [myTableView setDelegate:self.myDelegate];
    [myTableView setDatasource:self.myDelegate];
    

    Note: I currently have no access to a machine to test this, but just something to point you towards.

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

Sidebar

Related Questions

The prequel for this question is here . Now I've got another problem. I
This is my first time I am working on UITableView connected to custom delegate
The prequel for this question is here . I have a class (A) and
I was wondering how to overload the == operator for a binary tree to
So far I can get my code to highlite the specific td, but even
I'm creating a many to many relationship between content, but to simplify it I'll
It looks like my google search skills are to bad, I couldn't find answers
In the following scenario: I got a project having a catalog of currently some

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.