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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:02:22+00:00 2026-06-04T18:02:22+00:00

for my table view I have the following going on (paraphrased) .h @interface OptionsView

  • 0

for my table view I have the following going on (paraphrased)

.h

@interface OptionsView : UIView <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) NSArray *dataSource;

.m

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {

        ...

        self.dataSource = [NSArray arrayWithObjects:options, sections, sponsor,  nil];
    }
    return self;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(self.dataSource) {
        NSArray *ds = [self.dataSource objectAtIndex:indexPath.section];
        NSDictionary *d = [ds objectAtIndex:indexPath.row];
        ActionBlock a = [d objectForKey:ACTION]; // <-- Thread 1: EXC_BAD_ACCESS (code=2, address=0x802)
        if(a != nil) a();
    }
}

You can see that in my didSelectRowAtIndexPath I’m getting an EXC_BAD_ACCESS but I’m not sure why. Because I’m using arc it isn’t a zombie problem (already checked).

Using breakpoints I see that the self.dataSource exists after it’s initialized, but not later when it’s needed. It doesn’t show up as <nil> either, it’s just white space. Also, this works in debug but not in release so what does that mean?

** EDIT adding a screenshot **

You will notice that neither ds or d show up.. odd?
xcode debug

  • 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-04T18:02:24+00:00Added an answer on June 4, 2026 at 6:02 pm

    So there’s two places I can see that might cause the problem. First, what is ACTION? Is it some sort of NSString? Just want to make sure that you’re using a valid key object. Second, (and more likely the problem), it looks like ActionBlock is some kind of code block you’re storing in a collection array. Are you copying that block before you store it in the array/dictionary? You must copy any block you intend on keeping around (storing) longer than the scope it was created in. This is easy to do. For example:

    void (^NewBlock)(void) = [^{
        ....code....
    } copy];
    

    Alternately:

    void (^NewBlock)(void) = ^{
        ....code....
    };
    
    [dictionary setObject:[NewBlock copy] forKey:ACTION]; //Assuming #define ACTION @"action"
    

    This copies it onto the heap so that it can be stored. If you don’t copy it, you’ll get BAD_EXC_ACCESS anytime you try to reference the block outside the scope it was created in.

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

Sidebar

Related Questions

I have the following table in my view. <table> <tr> <th>Name</th> <th>Start</th> <th>End</th> </tr>
Inside my Table view controller I have following method -(BOOL)isValidCoordinate:(CLLocationCoordinate2D)coordinate { //This is just
I want have a table in my view that is going to put 3
I have the following code below. Firstly, in the table detail view, i capture
I have following view <asp:Content ID=Content2 ContentPlaceHolderID=MainContent runat=server> <h2>Tables <%=ViewData[RetriverName] %></h2> <%using (Html.BeginForm(ResfreshSelectedTables, Home))
I have view controller, into the view i have put a table view, and
I have 2 sections within a table view and I have loaded one section
When I have a table view with some sections which have their own headers
I have a Table View Controller with cells. I want to update the text
Ok, in CakePHP, I have the following code in my view add.ctp : echo

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.