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

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -