swift - Closure gets executed although its nil -
i have dynamic variable called "data" "data" variable nil. following closure gets executed anyways?
var data = dynamic<[pfuser]?>(nil) if let data = data.value{ print("data value \(data.value)") return }
is there solution problem?
you want check what's in dynamic, not dynamic var itself. (i.e. you've made new dynamic contains nil, haven't assigned nil data)
as is:
data ← dynamic( nil )
you want
data ← nil
try code this:
var data:dynamic<[pfuser]?>? = nil
or this:
var data = optional<dynamic<[pfuser]?>> = nil
now data optional containing nil
Comments
Post a Comment