kylef / JSONWebToken.swift

Swift implementation of JSON Web Token (JWT).
http://jwt.io
BSD 2-Clause "Simplified" License
763 stars 225 forks source link

Ambiguous reference to member 'encode(claims:algorithm:)' #88

Closed LCSomeSSSS closed 7 years ago

LCSomeSSSS commented 7 years ago

When I running the code as below on the Xcode8.3.2 it's showing the error:Ambiguous reference to member 'encode(claims:algorithm:)' so how can I fix the issue?

   `var claims = ClaimSet()
    claims.issuer = "fuller.li"
    claims.issuedAt = Date()
    claims["custom"] = "Hi"

    let stringValue = JWT.encode(claims:claims,algorithm: .hs256("secret".data(using: .utf8)))`
LCSomeSSSS commented 7 years ago

I solved this question that I just add ! in the back of utf8 then the error disappear. The right code as below: But I don't know the reason

     `let stringValue = JWT.encode(claims:claims,algorithm: .hs256("secret".data(using: .utf8)!))`