ios - How to create xcdatamodeld for particular database -


i've got table attributes: country, place, description etc. value of country attribute can repeated(one country can repeat 2 times or more).

i need db:

  1. all countries. (for tableview)
  2. all places particular country.(for tableview)
  3. other info particular place. (for details view)

so, question what's best way implement xcdatamodeld. thoughts:

  1. i can create simple entity without relationships. 1 , 2 points(described below) have go through managedobjects , thinks it's not thes best way.
  2. to use setpropertiestofetch:. think it's way i'm not sure okay leave database simple without relationships like(country -> place)
  3. i thought create 3 entities country, places, details. , load necessary data different entities. it's first experience coredata , i'm not sure make sense or no?

p.s. simple example. real database can more bigger , complicated.

the example trivial start simple as:

enter image description here

this how model if ignoring database - luckily coredata take care of persistence , can use models without thinking tables


you have concern efficiency once click on country. should use nsfetchedresultscontroller handle efficiently batching data ui , working tableview. set nsfetchedresultscontroller use predicate like:

[nspredicate predicatewithformat:@"country == %@", self.selectedcountry]; 

side note:

you should profile see if there real problem rather working on opinion of estimation


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -