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

sql - Time in datatime field -

javascript - How to split the success output from an Ajax post? -

java - sharing object across different classes -