0

Appleのコードを読んで、私は次を見てきました(キーチェーンサービスについて話しています):

query[kSecAttrService as String] = service as AnyObject?

の目的はAnyObject?何ですか?

次のように単純化できると思います

query[kSecAttrService as String] = service as AnyObject

どんな手掛かり?

これは、Apple のサンプルのスニペット全体です。

private static func keychainQuery(withService service: String, account: String? = nil, accessGroup: String? = nil) -> [String : AnyObject] {
    var query = [String : AnyObject]()
    query[kSecClass as String] = kSecClassGenericPassword
    query[kSecAttrService as String] = service as AnyObject?

    if let account = account {
        query[kSecAttrAccount as String] = account as AnyObject?
    }

    if let accessGroup = accessGroup {
        query[kSecAttrAccessGroup as String] = accessGroup as AnyObject?
    }

    return query
}
4

1 に答える 1