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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:22:13+00:00 2026-05-31T02:22:13+00:00

I am working on a iOS application, the model is very simple (Folders and

  • 0

I am working on a iOS application, the model is very simple (Folders and Documents), but I am having problems for making it working with NSFetchedResultsController.

The app uses a UITableView in a NavigationController for showing a list of folders and documents contained in a folder. The user can browse the folders hierarchy with a drilldown effect. Also, the user can copy/paste folders and documents, so any document or folder could have many parents.

This is my current model:

AbstractElement{
    elementName:string
}

Folder{
    parents<<---->>Folder.folders
    folders<<---->>Folder.parents
    documents<<---->>Document.parents
}

Document{
    numPages:int
    parents<<---->>Folder.documents
}

This model works fine if I fill the UITableView with an NSArray created from the current folder:

NSArray * currentListOfElements = 
      [[self.currentFolder.documents sortedArrayUsingDescriptors:descriptors] 
      arrayByAddingObjectsFromArray:
      [self.currentFolder.folders sortedArrayUsingDescriptors:descriptors]];

The problem is that I need to fill the UITableView from a NSFetchedResultsController, getting folders and documents with a single NSFetchRequest. The solution is something like that:

NSEntityDescription *entity = [NSEntityDescription 
                               entityForName:@"AbstractElement" inManagedObjectContext:self.context];
[fetchRequest setEntity:entity];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"%@ IN self.parents", self.currentFolder]];

...create the NSFetchedResultsController using fetchRequest...

But this doesn’t work because AbstractElement doesn’t have “parents” relationship.

If I move parent relationship from Folder and Document to AbstractElement the problem is how to set the inverse relation:

AbstractElement{
    elementName:string
    parents<<---->> ??
}

Folder{
    folders<<---->>Folder.parents
    documents<<---->>Document.parents
}

Document{
    numPages:int
}

Is this the right aproach? How could I use NSFetchedResultsController with my model? I don’t want to remove inverse relations because of the extra code that I need to implement.

Thanks.

  • 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-31T02:22:15+00:00Added an answer on May 31, 2026 at 2:22 am

    Louissmr,

    You say,

    … the user can copy/paste folders and documents, so any document or
    folder could have many parents.

    Hence, What is wrong with having 2 to-many relations in the AbstractElement. Call them, say, parents and children. It meets your criteria. Each is the inverse of the other.

    Andrew

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

Sidebar

Related Questions

I am working on importing an 3D CAD model into my iOS application, but
I'm working in an iOS application which uses libXML2 to read XML retrieved from
I've been working on a frequency detection application for iOS and I'm having an
I am working on a simple Table View iOS application, and I want to
I'm working on an iOS app where I want to load one view if
Working with dates in ruby and rails on windows, I'm having problems with pre-epoch
I need your help :( I'm working on a iOS application in which i
My iphoneos 3.1 based application is not working on iOS 4 GM: the camera
I am working on a Universal iOS Application on Xcode 4 . It's my
I am working in iOS 5,and before loading my application,I want to open a

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.