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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:12:55+00:00 2026-05-15T21:12:55+00:00

I’m having a problem with relationships between to entities in Core Data. I’m parsing

  • 0

I’m having a problem with relationships between to entities in Core Data. I’m parsing some JSON and adding the entities:

if ([hourSets isKindOfClass:[NSArray class]]) { // check to see that we have got some hours back

    for (NSDictionary *hourSet in hourSets) {

        Hourset *thisHourSet = (Hourset *)[NSEntityDescription
               insertNewObjectForEntityForName:@"Hourset"
               inManagedObjectContext:managedObjectContext];

        [thisHourSet setStartDate:[hourSet objectForKey:@"start_date"]];
        [thisHourSet setEndDate:[hourSet objectForKey:@"end_date"]];
        [record addHoursetsObject:thisHourSet];

    }

}

…and then later trying to grab them again:

NSSet *hourSets = [self.listing valueForKeyPath:@"hoursets.hourset"];   
NSLog(@"There are %@ hourSets", [hourSets count]);

I’m getting Program received signal: “EXC_BAD_ACCESS”. when trying to access that hourSets NSSet in any way, including just counting the items in it.

Any suggestions? Pretty stumped. Thanks!

  • 1 1 Answer
  • 4 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-15T21:12:56+00:00Added an answer on May 15, 2026 at 9:12 pm

    I am inferring your entity graph here but:

    [self.listing valueForKeyPath:@"hoursets.hourset"]
    

    … translates to a keypath of listing.hoursets.hourset which does not appear to return a set. Both the first and last elements are singular and therefore by convention not sets.

    I would suggest logging the class of the return to confirm what, if anything, you’re getting back.

    Update:

    (Forehead slap) The problem is actually the log statement itself. It should be:

    NSLog(@"There are %d hourSets", [hourSets count]);
    

    … because count returns an NSUInteger.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have some data like this: 1 2 3 4 5 9 2 6
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from

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.