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

Im still somewhat of a newbie on jQuery and the ajax scene, but I
I love the plots that ggplot generates. However, it is still somewhat cumbersome to
So I am still somewhat new to PHP, MySQL, and Javascript but I have
I do have somewhat of a feeling that people will try to beat me
Where I work we're still on .Net 2.0, but I'm somewhat familiar with the
Still new to Objective C, and I'm having some trouble that I just can't
I still very new using Subversion. Is it possible to have a working copy
I still have a large number of floppies. On some of them there probably
I still feel C++ offers some things that can't be beaten. It's not my
I'm still somewhat new to Java and trying to insert data into a database.

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.