Batuhan Kök
Batuhan Kök

Reputation: 1402

Xcode: Type of expression is ambiguous without more context

Xcode error: Type of expression is ambiguous without more context

How do I fix it?

let componentss = calendar.components(.CalendarUnitYear | .CalendarUnitMonth | .CalendarUnitDay | .CalendarUnitHour | .CalendarUnitMinute | .CalendarUnitSecond, fromDate: date)

Upvotes: 2

Views: 3994

Answers (2)

Batuhan Kök
Batuhan Kök

Reputation: 1402

Thanks it works!

dateFormat.dateStyle = NSDateFormatterStyle.ShortStyle
dateFormat.timeStyle = NSDateFormatterStyle.ShortStyle
datePicker.datePickerMode = UIDatePickerMode.DateAndTime
datePicker.addTarget(self, action: Selector("updateDateField:"),forControlEvents:UIControlEvents.ValueChanged)
yearLabel.inputView = datePicker

How do I convert this to dd-MM-yyyy H:mm:ss ?

Upvotes: 0

Code Different
Code Different

Reputation: 93161

CalendarUnit name has changed in Swift 2.0. Try this:

let componentss = calendar.components([.Year, .Month, .Day, .Hour, .Minute, .Second], fromDate: date)

Upvotes: 6

Related Questions