ios - Data is ambiguous for type lookup in this context? -


i converting project latest swift 3. stuck @ 1 position.

 func nsdatatojson(data: data) -> anyobject? {     {         return try jsonserialization.jsonobject(with: data, options: .mutablecontainers)     } catch let myjsonerror {         print(myjsonerror)     }     return nil } 

gives me error on func nsdatatojson(data: data) -> anyobject? { data ambiguous type lookup in context.

how can use in swift 3?

while using function in playground error

'jsonobject' produces 'any', not expected contextual result type 'anyobject?'

so after changing anyobject any, working

func nsdatatojson(data: data) -> any? {     {         return try jsonserialization.jsonobject(with: data, options: .mutablecontainers)     } catch let myjsonerror {         print(myjsonerror)     }     return nil } 

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? -