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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:18:50+00:00 2026-06-04T10:18:50+00:00

My car object has four passenger objects. The car needs to know where the

  • 0

My car object has four passenger objects. The car needs to know where the passengers are sitting, but the reverse relations wouldn’t make sense, i.e. frontPassengerSeatOccupant would be logical, but carWhosFrontPassengerSeatImSittingIn seems pointless (then I’d need three others for the other three seats), and I’d rather just have one carImSittingIn.

CoreData is recommending that I have inverse relationships for everything except in “advanced” cases, so I’m trying to abide by that. So I’m trying to do an ordered occupants relation, where seat 0 is driver, 1 is front passenger, 2 is rear driver, 3 is rear passenger. The problem occurs when I don’t have anybody in seat 1, but i have somebody in seat 2 or 3, because I can’t put a placeholder in the array.

What would be a clean way to implement this ordered, possibly empty seat problem while maintaining inverse relationships, and not having all these extra pointless properties?

  • 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-04T10:18:52+00:00Added an answer on June 4, 2026 at 10:18 am

    Two ways you could do this: provide an object that represents an unoccupied seat, or create an intermediate Seat object that contains the participants.

    Core Data models ordered relationships as an NSOrderedSet. NSOrderedSet stores objects contiguously (i.e. it won’t contain any nil values) You could create a dummy object that represents an unoccupied seat. You’d need to track the “null occupant” object, and I imagine you’d end up with a lot of complicated if ([occupant isNullOccupant]) logic to deal with this special case.

    The other solution, which I think is cleaner, is to have three entities: Car, Seat, and Occupant. A car would have a to-many relationship with Seat, and a Seat would have a to-one relationship with Occupant. Your model would look like this:

    Car <-->> Seat <<--> Occupant
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I have a managed object, Car. I have a RESTful search API sitting
I want to store a list of objects, lets say of type Car, but
I have the following list: IEnumerable<Car> cars; The Car object has a model and
My app has 3 kinds of objects: A, B and C. Each object is
From this document, Don't do this car = new Object(); car.make = Honda; car.model
Let's say I have a Car object which also has an Engine member, and
I have an object which itself has multiple objects as fields. The question I
So I'm getting this error; Object # has no method 'carName' But I clearly
If you have an NSSet with objects of type car. Car has two properties:
I have a Car object which contains a latitude field and a longitude field.

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.