Created
April 1, 2015 10:06
-
-
Save Gernot/18e08ea1cb446f445f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Time { | |
/* Is there any good way to do this without the intermediate vars? Swift 1.2 (Xcode 6.3b4) does not seem to let me write into the structs constants directly before initializing them. */ | |
init(date: NSDate) { | |
var hour: Int = 0, minute: Int = 0, second: Int = 0, nanosecond: Int = 0 | |
NSCalendar.currentCalendar().getHour(&hour, minute: &minute, second: &second, nanosecond: &nanosecond, fromDate: date) | |
self.hour = hour; self. minute = minute; self.second = second; self.nanosecond = nanosecond | |
} | |
let hour: Int | |
let minute: Int | |
let second: Int | |
let nanoSecond: Int | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swift can’t know if getHour will try to read uninit’ed vars, will initialise them, or keeps refs and write them later. So it's good this got
fixed
in 1.2 so it doesn't allow that anymore.I only see the option of using visibility modifiers.