I have the following line:
let jsonResults = NSData(contentsOfURL: Fetcher.URLforLicenseInfo())
This compiles and executes fine but if the initialisation of NSData fails I get an exception later in the code. I have tried to add another line:
if jsonResults != nil { ///blah, blah...
but then the compiler complains "Cannot invoke '!=' with an argument list type '(NSData, NilLiteralConvertible)"
Shouldn't the compiler recognise NSData initialiser return type as an optional?
check the length of the data : if(data.length > 0) ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With