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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:24:15+00:00 2026-05-24T08:24:15+00:00

This issue may have be raised here before, but I am not confident that

  • 0

This issue may have be raised here before, but I am not confident that I have understood the solution. Here is the problem, in Objective-C, Core Data, for iOS.

I am going to model a twitter-like User-Following relationship, One user can follow many, and be followed by many. The Following itself has attributes such as createTime, pending, and level – that means, I cannot merely let User has bidirectional relationships like follower and followed, like :

User <<->> User

but add one more entity, Following, with relationships like following and followed.

User <->> Following <<-> User

Here are two questions:

  1. Is this the best practice?

  2. If so, how to write a [aUser valueForKeyPath: …]; to fetch his/her followers or friends (being followed).

  • 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-24T08:24:15+00:00Added an answer on May 24, 2026 at 8:24 am

    Is this the best practice?

    I don’t think this problem falls into the category of “situations for which a best practice has been established”, but it seems like a reasonable solution.

    If so, how to write a [aUser valueForKeyPath: …]; to fetch his/her followers or friends (being followed).

    Let’s say that Following has a follower property for the person doing the following, and a leader property for the person being followed. Also, User has a leads property for the Following relationships with people who follow a user and a follows property for the Following relationships with people that the user follows. Finally, User also has a name property.

    Given all that, to get the names of aUser’s followers, you could say:

    NSSet *followers = [aUser valueForKeyPath:@”leads.follower.name”];

    and to get the names of people aUser follows:

    NSSet *leaders = [aUser valueForKeyPath:@”follows.leader.name”];

    It seems a little odd at first that you’d get sets back from those key paths since the last two keys in each path are singular. However, since the leads property returns a set of Following objects, leads.follower returns a set containing the users for each of those objects, and leads.follower.name returns a set containing the names of the users of those objects.

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

Sidebar

Related Questions

I'm currently struggling with this Collection was modified; enumeration operation may not execute issue.
I'm seeing this issue in Internet Explorer 8, but not in Safari or Firefox.
This may apply to other mobile operating environments than just Symbian... However, the issue
This issue is driving me mad. I have several tables defined, and CRUD stored
This issue is somewhat related: Problem with Code Generated by XSD.EXE: Sequence of Elements
Note: This issue appears to be limited to SQL Server 2005 SP2 I have
Update: This issue was not properly explored. The real issue lies within render :json
I've run into this issue quite a few times and never liked the solution
Okay, I think I might be over-complicating this issue but I truly am stuck.
I have a parallelism issue with my first advanced SSIS package. First, here is

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.