ios - Predicate to fetch child files and folders inside a parent folder with coredata -


i have situation apps core-data entities looks enter image description here

application intends works directory, user can add own files , folders.

i need provide search feature inside folders, user can search files or folders specific values (need iterate through child files , sub folders in sub levels).

can use nspredicate , nsfetchrequest this?

please advice.

if file , folder have many things in common ...
change model bit:

  1. make node abstract base class having properties:
    identifier
    title
    relationships:
    parent - to-one -> node
  2. inherit folder node , add relationship:
    children - to-many ->> node
  3. inherit file node , add properties:
    mimetype
    owner

take account create (under current coredata implementation) single table containing these properties , relationships.

you able search model nodes (files , folders) title matching given string. use predicate:

[nspredicate predicatewithformat:@"title contains[cd] %@",searchtext] 

however ... not complete solution can not limit search given parent node.

if need limit search, keep parent list each node adding to-many relationship node entity called parents. parents set set upon node parent relationship setting, taking new node parent parents set, coping , adding parent it, setting new node.

this allow more refined search using predicate:

[nspredicate predicatewithformat:@"any parents = %@ , title contains[cd] %@",basenode,searchtext] 

this optimised node may point specific parents set without coping on , on again, bit more complex.

you use nested sets or nested intervals implementation ... guess require lot of work on part.

all requests here done on node entity


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -