Невозможно вызвать значение нефункционального типа 'UIImage?'

Я пытаюсь запустить этот код, который рандомизирует UIImage. Но я получаю следующую ошибку Cannot call value of non-function type 'UIImage?

@IBOutlet weak var resultLabel: UILabel!
@IBOutlet weak var PersonsChoice: UIImageView!
var option = ["rock.png", "paper.png", "scissors.png"]

func chooseWinner(userChoice:Int){
    let randomNumber = Int(arc4random_uniform(3))
    PersonsChoice.image(option[randomNumber])

    if (randomNumber == 0 && userChoice == 1)
        || (randomNumber == 1 && userChoice == 2)
        || (randomNumber == 2 && userChoice == 0) {        
        resultLabel.text("You Win")
    } else if (userChoice == 0 && randomNumber == 1)
        || (userChoice == 1 && randomNumber == 2)
        || (userChoice == 2 && randomNumber == 0) {
        resultLabel.text("I Win!")
    } else {
        resultLabel.text("It's a draw!")
    }       
}

Я также получаю ошибку Cannot call value of non-function type 'String?' для resultLabel.text. Любая помощь приветствуется.


person user2167323    schedule 28.11.2015    source источник


Ответы (1)


Чтобы установить свойство image существующего UIImageView, вам нужно назначить ему новый экземпляр UIImage:

PersonsChoice.image = UIImage(named: option[randomNumber])

То же самое для text из UILabel:

resultLabel.text = "It's a draw!"
person veducm    schedule 28.11.2015
comment
Спасибо за вашу помощь Veducm. - person user2167323; 29.11.2015