Q:

Correct way of initializing stored properties? - Xcode 8.3.3 / Swift 3

I have a class like this: 
class Card: CustomStringConvertible {

// Init values
var id: UUID = UUID.init()
var shown: Bool = false
var image: UIImage
var sound: String = ""

init(image: UIImage) {
    self.image = image
}

init(sound: String) {
    self.sound = sound
}

init(card: Card) {
    self.id = (card.id as NSUUID).copy() as! UUID
    self.shown = card.shown
    self.image = card.image.copy() as! UIImage
    self.sound = card.sound
}

Why do I get an error ("Return from initializer without initializing all stored properties") in the init(sound: String) method. As far as I read it's important to set an initial value, what I did.

A:

In you init(sound: String) you don't assign any value to image.
Since this property is mandatory and none optional.
You have two options, make the property optional:
var image: UIImage? = nil

Or assign an new image object to it:
init(sound: String) {
    self.sound = sound
    self.image = UIImage()
}

