xcode - IOS Swift Unwrapping NSData is Crashing -


ios swift problem while unwrapping, crashing. getting data nsdata, when printing in string or

var dict : anyobject = nsjsonserialization.jsonobjectwithdata(returndata!, options: nsjsonreadingoptions(0), error: &resperror) anyobject! 

doing returning dict nil, or

var datastring : nsstring = nsstring(data:returndata!, encoding:nsutf8stringencoding)[this image liknk] as! string 

datastring causing fatal error:

unexpectedly found nil while unwrapping optional value.

you unwrapping values forcefully (forced unwrapping), if object contains nil generate runtime error.

trying use ! access non-existent optional value triggers runtime error. make sure optional contains non-nil value before using ! force-unwrap value.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -