ios - Core data and sorting after a join condition -



ios - Core data and sorting after a join condition -

i have 3 tables in core info tables. item table: items, has id column , connection properties table. properties table: has propertyvalue column , connection item table , connection property table. property table: has propertyname column , connection properties table.

the property table contains propertyname called "price". properties table contains propertyvalue "20" property "price". think can sort items table price?

i using nsfetchedresultscontroller , creating nsfetchrequest it. have tried write nssortdescriptor comparator block object nsfetchrequest. isn't working. after tried write nssortdescriptor without selector or block object, setup key called "dealprice" , created category on item managed object method called - (nsstring *)dealprice. wasn't working neither.

do know other method? or know solution?

you've got bad case of sql fever. trying treat core info sql wrapper , messing up.

core info not sql. entities not tables. objects not rows. attributes not columns. relationships not joins. core info object graph management scheme may or may not persist object graph , may or may not utilize sql far behind scenes so. trying think of core info in sql terms cause misunderstand core info , result in much grief , wasted time.

a core info datamodel should not configured depending on needs of ui or other non-data requirement. instead, should accurately model/simulate real world objects, events or conditions app deals with.

in case, modeling:

a type of property has name , price. an item denoted id of kind a relationship between 1 or more particular property instances , 1 or more instances of item.

therefore, info model needs 2 entities connected relationship. don't need "join" because relationship handles connection between 2 entities automatically.

the simplest model has one-to-one relationship:

item{ id:string property<-->property.item } property{ name:string price:number item<-->item.property }

if each item object can have several associated property objects have:

item{ id:string properties<-->>property.item } property{ name:string price:number item<<-->item.properties }

if each property object can have several associated item objects:

item{ id:string property<<-->property.items } property{ name:string price:number items<-->>item.properties }

how configure sort descriptors depends on details of relationships , entity's objects tableview display.

ios sorting core-data

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -