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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:01:29+00:00 2026-06-17T16:01:29+00:00

I have an entity called LogBook which has an attribute (called columns ) for

  • 0

I have an entity called LogBook which has an attribute (called columns) for a set of LogBookColumn entities (one-to-many relationship).

The standard way I see to retrieve the mutable set of columns seems to be:

NSEntityDescription *myLogbook;
myLogbook = [NSEntityDescription insertNewObjectForEntityForName:@"LogBook"
                                          inManagedObjectContext:self.managedObjectContext];
NSMutableSet *columns = [myLogbook mutableSetValueForKey:@"columns"];

Instead of method on the third line, I want to use dot notation. To do so, I have created class definitions, also called LogBook and LogBookColumn, and use @property to create the setters and getters.

LogBook *myLogBook;
myLogbook = [NSEntityDescription insertNewObjectForEntityForName:@"LogBook"
                                          inManagedObjectContext:self.managedObjectContext];
NSMutableSet *columns = (NSMutableSet *)myLogbook.columns;

So, is columns truly a mutable set by default? I have done two things to verify:

  • Attempted to write to the list, eg: [columns addObject:aColumn];
  • Asked with: BOOL isKindOfMutableSet = [myLogbook.columns isKindOfClass:[NSMutableSet class]];

Both work with expected results, which may make this question overkill, but I am very concerned about memory errors that will be difficult to track down. I also wonder if asking the question isKindOfClass will work as I have defined this as a mutable set – so won’t it work even if the underlying memory organization doesn’t support mutable sets?

All of the above sums up to: is this the right way to access and change the columns property/attribute?

  • 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-17T16:01:30+00:00Added an answer on June 17, 2026 at 4:01 pm

    According to this documentation, to-many relationships should be declared as NSSet, which makes sense. Even if the attribute returns an NSMutableSet, it is not guaranteed that updating the NSMutableSet will properly update relationships (which mutableSetValueForKey: does).

    If you really want a mutable accessor, then just create a readonly property that wraps mutableSetValueForKey:

    Update:

    Otherwise, we are supposed to use – (void)addLogBookColumnsObject:(LogBookColumn *)value;, – (void)removeLogBookColumnsObject:(LogBookColumn *)value;, – (void)addLogBookColumns:(NSSet *)values;, – (void)removeLogBookColumns:(NSSet *)values; that were generated by Core Data for us.

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

Sidebar

Related Questions

I have an entity called Entry , which has a one-to-many relationship with an
I have an entity called Band which has a to-many relationship to a Category
I have an entity called Person and a set of UIImages for it (One-To-Many).
Lets say I have an entity called User which has many Posts. My service
I have an entity called Foo. It has a nullable many-to-one association to Bar.
I have an entity called Attachment where it has a to-many relationship with no
I have an entity called guestlist that has a 1 to many relationship to
I have an entity called Samples . Inside that I have many fields, one
I have an entity called PendingPartners which has a navigation property to the Residents
Say I have an entity called Request that has collections of child entities like

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.