xcode - Displaying the Day Of The Week From Date Picker -


i want store day of week string using datepicker in xcode using swift.

import uikit class viewcontroller: uiviewcontroller {     @iboutlet weak var mydatepicker: uidatepicker!     @iboutlet weak var strweekday: uilabel!     override func viewdidload() {         super.viewdidload()         // additional setup after loading view, typically nib.         // set mode date         mydatepicker.datepickermode = uidatepickermode.date         // add target trigger update function change weekday when user changes date         mydatepicker.addtarget(self, action: selector("triggerupdate:"), forcontrolevents: uicontrolevents.valuechanged)         // weekday initial value         self.strweekday.text = mydatepicker.date.weekdayname     }     override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }     @ibaction func triggerupdate(sender: anyobject) {         self.strweekday.text = mydatepicker.date.weekdayname     } } extension nsdate {     // returns weekday name (sunday-saturday) string     var weekdayname: string {         let formatter = nsdateformatter(); formatter.dateformat = "eeee"         return formatter.stringfromdate(self)     } } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -