Objective-CからSwiftへの変換


Objective-CからSwiftに書き直しているのですがうまく書き直せません。

# Objective-C

[code]

    NSMutableDictionary * queryPublicKey = [[NSMutableDictionary alloc] init];
    [queryPublicKey setObject:(__bridge id)kSecClassKey forKey:(__bridge id)kSecClass];
    [queryPublicKey setObject:publicTag forKey:(__bridge id)kSecAttrApplicationTag];
    [queryPublicKey setObject:(__bridge id)kSecAttrKeyTypeRSA forKey:(__bridge id)kSecAttrKeyType];
    
[/code]

# Swift

[code]

    var queryPublicKey = NSMutableDictionary()
        queryPublicKey = [kSecClass: kSecClassKey,
                          kSecAttrApplicationTag: keychainIdentifierData,
                          kSecAttrKeyType: kSecAttrKeyTypeRSA]
    
[/code]

Objective-Cを元に書き直すと

> 「Value of type 'CFString' does not conform to expected dictionary key type
> 'NSCopying'」

とエラーを吐きます。  
何かしら一手間必要なのでしょうか。



[code]

    var queryPublicKey = NSMutableDictionary()
    queryPublicKey = [kSecClass as NSString: kSecClassKey,
                      kSecAttrApplicationTag as NSString: keychainIdentifierData,
                      kSecAttrKeyType as NSString: kSecAttrKeyTypeRSA]
    
[/code]

`CFString` を `NSString` にキャストする必要があります。



[code]

    var queryPublicKey = NSMutableDictionary()
    queryPublicKey = [kSecClass as NSString: kSecClassKey,
                      kSecAttrApplicationTag as NSString: keychainIdentifierData,
                      kSecAttrKeyType as NSString: kSecAttrKeyTypeRSA]
    
[/code]

`CFString` を `NSString` にキャストする必要があります。

