[ad_1]
Requested
Seen
24 occasions
A part of my Code which is inside the category fetchData()
@Printed var deviceNmae : String = ""
@Printed var deviceID : String = ""
init(){
self.deviceID = "t1199"
}
let urlString = "https://io.adafruit.com/(deviceID)/"
error i get is
Can't use occasion member 'deviceID' inside property initializer; property initializers run earlier than 'self' is out there
How am i able to resolve this ? i seemed into comparable questions in stackOverflow however nothing appears to be working can someOne information me with this
Karan D is a brand new contributor to this web site. Take care in asking for clarification, commenting, and answering.
Take a look at our Code of Conduct.
0
Two choices:
- Use a lazy var:
lazy var urlString = "https://io.adafruit.com/(deviceID)/"
- Use a computed property
var urlString: String { "https://io.adafruit.com/(deviceID)/" }
2
Not the reply you are in search of? Browse different questions tagged ios swift xcode or ask your individual query.
lang-swift
[ad_2]
