InternationalCodingGuru
InternationalCodingGuru

Reputation: 2258

core data with tree structure - return only 1 level

I'm using Core Data and I have a file-folder tree-like structure. So I've created 2 subclasses of NSManagedObject as follows:

FolderMO
Attributes:
  - FolderName
Relationships:
  - the FolderMO itself (since it can have sub-folders)
  - FileMO (it can have a list of files that belong in the folder)

FileMO
Attributes:
  - FileName

The data that I need to store is essentially 3 levels of folders, and then a level of files. On the 1st level I have ~20 Folders, and each Folder has ~20 sub-folders, and each sub-folder has a number of sub-sub-folders, and then finally I have the files that belong in said-folder. I have ~10,000 files total that I need to store.

My Question
Is there a way that I can retrieve only 1 level of my data at a time? ie: Will Core Data let me retrieve only the 1st level of folders to display to the user. Then, if they make a selection, I will retrieve the next level based on their selection? I don't want to have to load all my data into memory at once, especially since the user may not even use this portion of the application.

Thanks!

Sunny

Upvotes: 0

Views: 318

Answers (1)

RolandasR
RolandasR

Reputation: 3046

Core data wont load all objects until you access them

Upvotes: 1

Related Questions