This is a hitlist
Import Uikitimport coredataclass Viewcontroller:uiviewcontroller,uitableviewdatasource {var names = [String] () var People = [Nsmanagedobject] () @IBOutlet weak var tableview:uitableview! Override func Viewwillappear (Animated:bool) {super.viewwillappear (animated) Let Appdelegate = Uiap Plication.sharedapplication (). Delegate as! Appdelegate Let Managedcontext = appdelegate.managedobjectcontext let fetchrequest = Nsfetchrequest ( EntityName: "Person") does {let results = Try Managedcontext.executefetchrequest (fetchrequest) People = Results as! [Nsmanagedobject]} Catch let error as nserror {print ("Could not fetch \ (error), \ (Error.userinfo)}}} override Func viewdidload () {super.viewdidload ()//Do any additional setup after loading the view, typically from a Nib. title = "\" The List\ ""//Tableview.registerclass (UitaBleview.self, Forcellreuseidentifier: "Cell")} @IBAction func AddName (sender:anyobject) {var a Lert = Uialertcontroller (title: "New Name", Message: "Add a New name", Preferredstyle:. Alert) Let saveaction = uialertaction (title: "Save", Style:. Default) {(action:uialertaction!), Void in Let TextField = alert.textfields!. First Self.savename (textfield!. text!) Self.tableView.reloadData ()} Let Cancelaction = Uialertaction (title: "Cancel", Style:.) Default) {(action:uialertaction!), Void in} alert.addtextfieldwithconfigurationh Andler {(textfield:uitextfield!), Void in} alert.addaction (Saveaction) Al Ert.addaction (cancelaction) presentviewcontroller (Alert, Animated:true, Completion:nil)} func Savename (name:string) {Let appdelegate = Uiapplication.sharedaPplication (). Delegate as! Appdelegate Let Managedcontext = appdelegate.managedobjectcontext let entity = NSENTITYDESCRIPTION.E Ntityforname ("person", inmanagedobjectcontext:managedcontext) let person = Nsmanagedobject (entity:entity! , Insertintomanagedobjectcontext:managedcontext) person.setvalue (name, Forkey: "name") do { Try Managedcontext.save () people.append (person)} catch let error as nserror {PR Int ("Could not save\ (error), \ (Error.userinfo)")}} func TableView (Tableview:uitableview, Numberofrowsin Section Section:int), Int {return people.count} func tableView (Tableview:uitableview, Cellforrow Atindexpath Indexpath:nsindexpath), UITableViewCell {let cell = Tableview.dequeuereusablecellwithide Ntifier ("Cell")! As UITableViewCell let person = People[indexpath.row] Cell.textlabel?. Text = PersOn.valueforkey ("name") as! String? Return cell} override func didreceivememorywarning () {super.didreceivememorywarning ()//Dispose of Any resources the can be recreated. }}
Initial knowledge of iOS development CoreData