swift - how would i skip displaying certain entries when populating cell rows from core data in a tableviewcontroller? -
for app i'm working on, have saved several items coredata model.
my intention selectively print them out tableview based on whether attributes true.
example given items in coredata:
/////////////////////
1--name: joe, display: true
2--name: sally, display:false
3--name: bob, display:false
4--name: jess, display:true
/////////////////////
i want table view display cells display true out of 4 entries joe , jess listed in tableview
so far, know how print out every single item. table view datasource protocol
thanks helping out noob!
i this:
// entity here called "users"
var myusers = [users]() var fetchrequest = nsfetchrequest(entityname: "users") allow predicate = nspredicate(format: "display = %@", true) fetchrequest.predicate = predicate // maybe sort? var sortdescriptor = nssortdescriptor(key: "userid", ascending: true) var sortdescriptors = [sortdescriptor] fetchrequest.sortdescriptors = sortdescriptors myusers = context!.executefetchrequest(fetchrequest, error: nil) [users]
// utilize them in tableview (cellforrowatindexpath)
var myuser = myusers[indexpath.row] users
swift ios8 xcode6
No comments:
Post a Comment