Cannot convert value of type 'NSRange' (aka 'NSRange') to expected argument type 'Range<Index>' (aka 'Range<Int>')
<p>i'm trying to implement Easy Game Center <a href="https://github.com/DaRkD0G/Easy-Game-Center-Swift" rel="nofollow noreferrer">link</a> but i get this error: </p>

<blockquote>
  <p>Cannot convert value of type 'NSRange' (aka 'NSRange') to expected
  argument type 'Range&lt;Index>' (aka 'Range&lt;Int>')</p>
</blockquote>

<p>here is the code: </p>

<pre><code> static func unarchive(_ data: Data!) -&gt; Packet {
    var archivedPacket = ArchivedPacket(index: 0, numberOfPackets: 0, nameLength: 0) //, dataLength: 0
    let archivedStructLength = sizeof(ArchivedPacket)

    let archivedData = data.subdata(in: NSMakeRange(0, archivedStructLength))
    (archivedData as NSData).getBytes(&amp;archivedPacket)

    let nameRange = NSMakeRange(archivedStructLength, Int(archivedPacket.nameLength))
    let nameData = data.subdata(in: nameRange)
    let name = NSString(data: nameData, encoding: String.Encoding.utf8) as! String
    let packet = Packet(name: name, index: archivedPacket.index, numberOfPackets: archivedPacket.numberOfPackets)

    return packet
}
</code></pre>

<p>edit: here is the entire code of the struct:</p>

<pre><code>import Foundation
/**
*  Packet
*/
struct Packet {
    var name: String
    var index: Int64
    var numberOfPackets: Int64

    /**
    *  Struc
    */
    struct ArchivedPacket {
        var index : Int64
        var numberOfPackets : Int64
        var nameLength : Int64
    }
    /**
    Archive Packet

    - returns: NSData
    */
    func archive() -&gt; Data {

        var archivedPacket = ArchivedPacket(index: Int64(self.index), numberOfPackets: Int64(self.numberOfPackets), nameLength: Int64(self.name.lengthOfBytes(using: String.Encoding.utf8)))

        let metadata = Data(
            bytes: UnsafePointer&lt;UInt8&gt;(&amp;archivedPacket),
            count: sizeof(ArchivedPacket)
        )

        let archivedData = Data(data: metadata) as Data
        archivedData.append(name.data(using: String.Encoding.utf8, allowLossyConversion: false)!)

        return archivedData
    }
    /**
    Unarchive Packet

    - parameter data: NSData

    - returns: Packet
    */
    static func unarchive(_ data: Data!) -&gt; Packet {
        var archivedPacket = ArchivedPacket(index: 0, numberOfPackets: 0, nameLength: 0) //, dataLength: 0
        let archivedStructLength = sizeof(ArchivedPacket)

        let archivedData = data.subdata(in: NSMakeRange(0, archivedStructLength))
        (archivedData as NSData).getBytes(&amp;archivedPacket)

        let nameRange = NSMakeRange(archivedStructLength, Int(archivedPacket.nameLength))
        let nameData = data.subdata(in: nameRange)
        let name = NSString(data: nameData, encoding: String.Encoding.utf8) as! String
        let packet = Packet(name: name, index: archivedPacket.index, numberOfPackets: archivedPacket.numberOfPackets)

        return packet
    }
}
</code></pre>