swift - Initialzer for conditional binding must have Optional type not 'String' -


compiler throwing error "initialzer conditional binding must have optional type not 'string'"

if let classstring = string.fromcstring(class_getname(currentveiw?.dynamictype)){ } 

the compiler telling you can't use if let because it's totally unnecessary. don't have optionals unwrap.if let used exclusively unwrap optionals. use:

let classstring = string(describing: type(of: currentveiw!)) 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -