swift3 - Swift 3 Convert Double to String -


i keep getting error "initializer conditional binding must have optional type, not 'double'". trying display core data values , 1 double. ive tried work around same way had store values when converting it.

heres code gives me error:

func displaystats() {            // display other attributes if have values         if let servingsize  = mealstats.serving {             servingslabel.text = servingsize          } 

mealstats.serving of type "double" , not "double?"
since not optional cannot unwrapped. right way use be

func displaystats() {     // display other attributes if have values     servingslabel.text = "\(mealstats.serving)" } 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -