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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:07:45+00:00 2026-05-17T17:07:45+00:00

Still somewhat of a newbie… I have an NSMutableArray that stores filenames – when

  • 0

Still “somewhat” of a newbie… I have an NSMutableArray that stores filenames – when a user clicks a UITableView the corresponding selected cell will pass the certain filename in the array to MPMoviePlayerController to play. It works, however if I exit out of the viewcontroller and come back, only the last video that I played will work, if I select any other table entry, I get a crash with “EXEC_BAD_ACCESS”. So I’m assuming the array is being released when the view controller disappears
Here is the code:

first off: “NSMutableArray *filenameArray;” is in the .h file

(void)viewDidLoad 
{
  [super viewDidLoad];
  //filenameArray = [[[NSMutableArray alloc]    initWithCapacity: 500] autorelease];
  filenameArray = [[NSMutableArray alloc] initWithCapacity: 500];    
}

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

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

  // Configure the cell...
  NSString *fullPath = [[NSString alloc] init];
  fullPath = [[_importableVideoDocs    objectAtIndex:indexPath.row]    description];
  NSLog(@"Full path is: %@", fullPath);
  [filenameArray addObject:fullPath];
  NSString *fileName = [fullPath lastPathComponent];
  [fullPath release];

  cell.textLabel.text = fileName;
  return cell;    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath    *)indexPath 
{
  NSLog(@"Tapping row %d", indexPath.row);
  NSUInteger i = (indexPath.row);
  NSString *test = [[filenameArray objectAtIndex:i] description];

  //CRASH HAPPENS HERE IF VIEW CONTROLLER IS DISMISSED AND THEN    APPEARS AGAIN
  //when view disappears is filenameArray released? do I need to    retain?

  NSLog(@"%@", test);

  moviePlayer = [[[CustomMoviePlayerViewController    alloc] init] autorelease];

  // Show the movie player as modal
  [self presentModalViewController:moviePlayer    animated:YES];

  // Prep and play the movie
  [moviePlayer readyPlayer:test];
}

So my “newbie” question is, how do I retain this to stop the EXC_BAD_ACCESS crash when I click the table when the view appears for the second time? or if I’m not on the right track to the answer, what do I need to do to stop this crash? If anyone could help me with how I might solve this it would be greatly appreciated!
Thanks!

  • 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-17T17:07:45+00:00Added an answer on May 17, 2026 at 5:07 pm

    EXC_BAD_ACCESS usually means you’re trying to use a variable that has been released. If the crash happens where you indicated its either the array or the object stored in the array. You can try adding more NSLogs before the crash, but as Nick suggested, the debugger is your friend.

    If I had to guess, I’d say try the following:

    NSString *fullPath = [[NSString alloc] initWithString:[[_importableVideoDocs objectAtIndex:indexPath.row] description]];
    

    I think the way you’re coding it now allocs a String, then leaks it when it’s replaced by the description. The description I think would be autoreleased, so when you release it later bad stuff might happen. By using initWithString you ensure the right retain count.

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

Sidebar

Related Questions

I have a SQL question that I could use some help with. Still somewhat
Im still somewhat of a newbie on jQuery and the ajax scene, but I
After researching various hosts, I still get the feeling that it is somewhat impossible
Still an iphone dev starter but trying. I would like to have the user
I am somewhat newbie for linux, still learning. Today I needed to duplicate a
I have a messages table that is structured somewhat like this: from | to
So I am still somewhat new to PHP, MySQL, and Javascript but I have
I love the plots that ggplot generates. However, it is still somewhat cumbersome to
I'm still pretty new to programming so I have somewhat of a noob question.
I'm still somewhat of a novice with Xcode. I have added a third party

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.