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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:05:50+00:00 2026-05-13T07:05:50+00:00

IN a bit of a pickle. I am implementing a CoreData solution and I

  • 0

IN a bit of a pickle. I am implementing a CoreData solution and I have two entities, Site and Post. Now Site has many Posts as Post belongs to one Site, as reflected in the model diagram.

In my entity code I have :

Site.h

@property (nonatomic, retain) NSString * name;
@property (nonatomic, retain) NSString * url;
@property (nonatomic, retain) NSSet* post;
@property (nonatomic, retain) NSSet* tag;
   ...
@interface Site (CoreDataGeneratedAccessors)
 - (void)addPostObject:(Post *)value;
 - (void)removePostObject:(Post *)value;
 - (void)addPost:(NSSet *)value;
 - (void)removePost:(NSSet *)value;

Post.h

@property (nonatomic, retain) NSDate * date;
@property (nonatomic, retain) NSNumber * views;
@property (nonatomic, retain) NSSet* comment;
@property (nonatomic, retain) Site * site;
...
@interface Post (CoreDataGeneratedAccessors)
 - (void)addCommentObject:(Comment *)value;
 - (void)removeCommentObject:(Comment *)value;
 - (void)addComment:(NSSet *)value;
 - (void)removeComment:(NSSet *)value;

 - (void)addMediaObject:(Media *)value;
 - (void)removeMediaObject:(Media *)value;
 - (void)addMedia:(NSSet *)value;
 - (void)removeMedia:(NSSet *)value;
@end

My issue is, i need to access a post that belongs to a Site, so i guess I logically need to get an array of all the posts belonging to a user. can someone provide me sample code to do this? Ive been scouring the internet to find sample code but yeah, no luck so far

  • 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-13T07:05:50+00:00Added an answer on May 13, 2026 at 7:05 am

    How are you associating a user with a post in the first place? I don’t see any attribute or relationship in your posted code that associates a user… but, for the sake of argument, let’s assume that a Post entity has an attribute named user (for this simple example, user is just an NSString that identifies the user by name).

    NSString* user = @"our_username";
    NSFetchRequest* request = [[[NSFetchRequest alloc] init] autorelease];
    NSPredicate* predicate = [NSPredicate predicateWithFormat:@"SELF.user LIKE[cd] %@", user];
    [request setEntity:[NSEntityDescription entityForName:@"Post" inManagedObjectContext:someContext]];
    [request setPredicate:predicate];
    NSError* error = nil;
    NSArray* postsForUser = [someContext executeRequest:request error:&error];
    if( !postsForUser ) {
      // handle error
    }
    
    // Will contain all posts by user
    NSLog(@"posts: %@", postsForUser);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of a pickle here and wonder if anyone can give
I am in a bit of a pickle. I have a few Mac Minis
Hi guys I'm in a bit of a pickle here now. Well to start
I'm in a bit of a pickle here. I have an action for which
I've seemed to have gotten myself into a bit of a pickle. I'm trying
I am in a bit of a pickle right now. I am building a
Bit of a strange question. I have a website which has some pages in
Got myself in a bit of a pickle here ... working on a CMS
I'm in a bit of a pickle. I'm trying to run some environmental scripts
I'm in a bit of a pickle at work. My department designs a number

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.