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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:08:22+00:00 2026-06-05T15:08:22+00:00

I have a vehicle entity in my data model. It has name, make, model,

  • 0
  • I have a vehicle entity in my data model.
  • It has name, make, model, etc attributes.
  • I’ve got a modal segue to the NewVehicleViewController which allows the user to enter entity information.
  • I’ve passed the managedObjectContext to the NewVehicleViewController during this segue
  • Clicking ‘Done’, creates a new NSEntityDescription by calling the create+vehicle.m’s method from within the NewVehicleViewController’s IBAction method.

    Vehicle *car = [Vehicle vehicleWithName:name inManagedObjectContext:self.context];

This method does the following:

+ (Vehicle *) vehicleWithName:(NSString *)name inManagedObjectContext:(NSManagedObjectContext *) context
{
    Vehicle *vehicle = nil;

    //check for duplicates
    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Vehicle"];
    request.predicate = [NSPredicate predicateWithFormat:@"name = %@", name];
    NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
    request.sortDescriptors = [NSArray arrayWithObject:sortDescriptor];

    NSError *error;
    NSArray *matches = [context executeFetchRequest:request error:&error];
    NSLog(@"Matches: %d", matches.count);

    if(!matches || [matches count] >1){
        //nil or more than 1
    } else if ([matches count] == 0){
        //not found
        vehicle = [NSEntityDescription insertNewObjectForEntityForName:@"Vehicle" inManagedObjectContext:context];
        vehicle.name = name;
    }else{
        vehicle = [matches lastObject];
        NSLog(@"vehicle already exists with name: %@", name);
    }

    NSLog(@"Created vehicle with name: %@", vehicle.name);

    return vehicle;
}

When the window closes, and I return back to my Table View controller, I can see the new element in there. (This table is linked to a fetch statement). Everything’s all good.

Then about 4-6 seconds later, I get an exception thrown. The debug log at the bottom shows nothing, and it brings me to a Thread 8 view with a break on the first line.

libobjc.A.dylib`objc_exception_throw:
0x1780caa:  pushl  %ebp
0x1780cab:  movl   %esp, %ebp
0x1780cad:  pushl  %ebx
0x1780cae:  pushl  %edi
0x1780caf:  pushl  %esi
0x1780cb0:  subl   $2028, %esp
0x1780cb6:  calll  0x01780cbb               ; objc_exception_throw + 17

So my first question is, any idea what the problem is? Is this happening due to the NS Core Data’s auto save that’s happening some time later?

And my second question is, how could I have debugged this further to find out what the problem is?

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-06-05T15:08:25+00:00Added an answer on June 5, 2026 at 3:08 pm

    Turns out, I renamed the entity in the model from Car to Vehicle. I propagated the changes through the code, but the simulator still had the app saved on it. The database inside the app had original Cars still stored in it, but now they are called Vehicles.

    This was causing an exception to occur after a save.

    I ended up delete the app from the simulator, and then running it again, and it worked.

    Thanks!

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

Sidebar

Related Questions

I have a class which has a variety of details, as follows: Vehicle Name
I have a database which has a table recording when a vehicle was last
Let's say I have a model called Vehicle Ext.define('AM.model.Vehicle', { extend: 'Ext.data.Model', fields: [
I have a model Vehicle which actually maps to the at_vehicles table. So while
I have a Vehicle model: class Vehicle < ActiveRecord::Base validates_presence_of :num_of_wheels validates_presence_of :make validates_presence_of
How can I get the foreign key values? I have a common vehicle model
I have a Vehicle model: Routes: map.resources :vehicles, :has_many => :suppliers Everything works great,
Let's say I have a model Vehicle and it has_many :wheels What is the
I have the following vehicle data vehicle_id, position_x, position_y, time The data represents the
I will explain the problem with an example. I have a Vehicle object which

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.