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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:10:42+00:00 2026-05-30T02:10:42+00:00

I have a Core Data stack in which there are two entities: ‘Client’ and

  • 0

I have a Core Data stack in which there are two entities: ‘Client’ and ‘Car’. Both are represented by tableViewControllers.

The first tableViewController fetches the list of clients and then once selected, the second displays a list of cars that client owns. Both are pushed onto a navigation controller. When I go ‘back’ from the second viewcontroller the program shows the firstviewcontroller successfully, waits a second or so then crashes. When I did a ‘build and debug’ the console gave this error:

Program received signal:  “EXC_BAD_ACCESS”.

I dont understand it. Where should I look to find the error?

EDIT:I have included some code below to see if it is due to bad memory handling… I have deleted all commented out methods and as well as those not used before error crops up.

This is my ClientListViewController…

@implementation ClientListViewController

@synthesize clientsArray;
@synthesize coreDataModel;

#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
    [super viewDidLoad];

    // Set the title
    self.title=@"Clients";

    [self populateTable];
}

-(void)populateTable {

    [self setClientsArray:[coreDataModel retrieveClientList]];

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Override to allow orientations other than the default portrait orientation.
    return YES;
}


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [clientsArray count];
}


// Customize the appearance of table view cells.
- (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...

    Client *client = (Client *)[clientsArray objectAtIndex:indexPath.row];
    cell.textLabel.text = [client name];

    return cell;

    [client release];


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    // Create and push new view controller.
    ClientCarsViewController *clientCarsViewController = [[ClientCarsViewController alloc] initWithNibName:@"ClientCarsViewController" bundle:nil];

    //Pass the CoreDataModel to the view controller
    clientCarsViewController.coreDataModel = coreDataModel;

    // Pass the selected object to the new view controller
    Client *client = (Client *)[clientsArray objectAtIndex:indexPath.row];
    clientCarsViewController.client = client;

    // Push the new viewController
    [self.navigationController pushViewController:clientCarsViewController animated:YES];

    // Release the objects
    [clientCarsViewController release];
    [client release];

}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    self.clientsArray = nil;
}


- (void)dealloc {

    [clientsArray release];
    [coreDataModel release];
    [super dealloc];

}


@end

This is my ClientCarsViewController implementation…

@implementation ClientCarsViewController

@synthesize carsArray;
@synthesize coreDataModel;
@synthesize client;


#pragma mark -
#pragma mark View lifecycle


- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = client.name;

    // Get client's cars
    NSSet *cars = client.cars;

    // Import them into the carsArray
    [self setCarsArray: [NSMutableArray arrayWithArray:[cars allObjects]]];

    [cars release];

}

-(void)addCarToClient {

    [coreDataModel addCarToClient:(Client *)client];

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Override to allow orientations other than the default portrait orientation.
    return YES;
}


#pragma mark -
#pragma mark Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return [carsArray count];

}


// Customize the appearance of table view cells.
- (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...
    Car *car = (Car *)[carsArray objectAtIndex:indexPath.row];
    cell.textLabel.text = [car carName];
    return cell;

    [car release];

}


#pragma mark -
#pragma mark Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.

}


#pragma mark -
#pragma mark Memory management

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Relinquish ownership any cached data, images, etc. that aren't in use.
}

- (void)viewDidUnload {
    // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
    self.carsArray = nil;
}


- (void)dealloc {

    [self.client release];
    [self.coreDataModel release];
    [self.carsArray release];
    [super dealloc];
}


@end
  • 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-30T02:10:44+00:00Added an answer on May 30, 2026 at 2:10 am

    You are releasing objects you don’t own. Have o look at Objective-C Memory Management Rules.

    For example, when you obtain an object client like this:

    Client *client = (Client *)[clientsArray objectAtIndex:indexPath.row];
    

    You don’t own it and should not release it.

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

Sidebar

Related Questions

I have a core data stack which contains an entity called 'Client'. Each client
I have started creating an app which uses a core data stack at the
I have a Core Data entity which needs a gender property. I just need
I have an Core Data Entity with a number of attributes, which include amount(float),
I have a core data application which uses a navigation controller to drill down
I have set up a Core Data model where I have two objects, say
I have a question concerning Core Data and how, if at all, Entities get
I have an NSOperation subclass which uses Core Data. It has a custom init
I'm using core data and I have a simple two-entity model. My navigation controller
I have some entities in core data, and they are all sub classes of

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.