SDK 8.3 Immutable ... only has mutating members named 'append'

I upgraded to Xcode SDK 8.3 and Swift 1.2: I automatically converted using the new menu item: Edit → Convert → "To last Swift Syntax". He decided everything how? errors, but I was left with this:

An immutable value of type '[DetailView]' has only mutating elements named 'append'

class DetailView

class DetailView { var title: String var icon: UIImage var fontColor: UIColor var highlightOpaqueColor: UIColor init(title: String, icon:UIImage, fontColor: UIColor, highlightOpaqueColor: UIColor){ self.title = title self.icon = icon self.fontColor = fontColor self.highlightOpaqueColor = highlightOpaqueColor } 

class DetailViewSteps: DetailView

 class DetailViewSteps:DetailView { override init( title: String, icon: UIImage, fontColor: UIColor, highlightOpaqueColor:UIColor){ super.init( title: title, icon: icon, fontColor:fontColor, highlightOpaqueColor:highlightOpaqueColor, } 

class DetailViewInstanceList

 class DetailViewInstanceList { let detailView:[DetailView] = [] class var sharedInstance: DetailViewInstanceList { struct Singleton { static let instance = DetailViewInstanceList() } return Singleton.instance } let assets = Assets() init(){ println("setting up DetailViewInstanceList") var steps = DetailViewSteps( title: "Steps", icon: UIImage(named: assets.stepsIconFileName)!, fontColor: assets.stepsFontColor, highlightOpaqueColor: assets.stepsOpaqueColor, //Add it to the array detailView.append(steps) <-- error! 

Error on the last line. I thought that initializing the class using var steps = DetailViewSteps (... will solve immutable, but no. Any help would be greatly appreciated! Thanks

0
source share
1 answer

var detailView:[DetailView] = []

let is immutable; var is mutable.

+1
source

Source: https://habr.com/ru/post/985037/


All Articles