I could not find a better way to do this. I map all the properties of the student object in a two-dimensional array. Therefore, my TV has sections.
I cannot use Static Tableview if this problem did not exist.
So my code is in TVC
let currentUser = PFUser.currentUser()! as! MyUser var membershipSection:[[String:String]]! var detailsSection:[[String:String]]! var emergancySection:[[String:String]]! var medicalSection:[[String:String]]! var titlesForSection = ["MEMBERSHIP", "DETAILS", "EMERGANCY CONTACT", "MEDICAL HISTORY"] var combo = [[[String:String]]]() // Data Source for TableView
// Called from ViewDidLoad
func loadDisplayDataSource() { combo.removeAll(keepCapacity: true) var idString = "Awaiting ID Generation" if student.objectId != nil { idString = student.objectId! } membershipSection = [["Sessions":student.sessionsRemaining], ["Details":""], ["ID":idString]] detailsSection = [["First Name":student.firstName], ["Last Name":student.lastName], ["DOB":""], ["Address":""], ["Phone":""], ["Email":student.email], ["Occupation":""]] emergancySection = [["Name":""], ["Phone":""]] medicalSection = [["Recent Surgery":""], ["Hypertension":""], ["Diabetes":""], ["Caradic":""], ["Epilesy":""], ["Syncope":""], ["Medications":""], ["Medical Details":""], ["Other Injuries":""]] combo.append(membershipSection) combo.append(detailsSection) combo.append(emergancySection) combo.append(medicalSection) self.tableView.beginUpdates() var range = NSMakeRange(0, self.numberOfSectionsInTableView(self.tableView)) var sections = NSIndexSet(indexesInRange: range) self.tableView.deleteSections(sections, withRowAnimation: UITableViewRowAnimation.None) self.tableView.insertSections(sections, withRowAnimation: UITableViewRowAnimation.Fade) self.tableView.endUpdates() }
Is there a better way to map object data to partitions? The way I do this works, but a little confusing. If I could use a static view, that would be simpler, but I cannot use drop on the TV in Normal VC, and you cannot use static TV in them. What is annoying! Is there a cleaner way?
Can I make it more SWIFTY - the best way to create my combo data source.
Thanks for any advice.
My end result, which works, is as follows: TVC with partitions.
