Search code examples
swiftswift3cfdictionary

Cast Swift Dictionary to CFDictionary


What is the right way to cast Dictionary in Swift 3 to a CFDictionary? Is it legal to write like this?

 var dictionary:Dictionary<NSString, Int> = [:]

and then

 dictionary as CFDictionary

Solution

  • Yes you can do that. your solution will work and you can also do it like this.

    var dictionary = [
    
        key:value
    
    ] as CFDictionary
    

    You can refer further from here