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:
- all countries. (for tableview)
- all places particular country.(for tableview)
- other info particular place. (for details view)
so, question what's best way implement xcdatamodeld. thoughts:
- i can create simple entity without relationships. 1 , 2 points(described below) have go through managedobjects , thinks it's not thes best way.
- to use setpropertiestofetch:. think it's way i'm not sure okay leave database simple without relationships like(country -> place)
- 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:
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
Post a Comment