Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe Pointer Errors #31

Open
traviskirton opened this issue Oct 12, 2016 · 1 comment
Open

Unsafe Pointer Errors #31

traviskirton opened this issue Oct 12, 2016 · 1 comment
Assignees

Comments

@traviskirton
Copy link
Contributor

In Gesture.swift, Packet.swift, and ResonateShapeGenerator.swift, I get the following error:

Cannot invoke initializer for type 'UnsafePointer<UInt32>' with an argument list of type '(UnsafeRawPointer)'

screen shot 2016-10-12 at 2 08 48 pm

public init(_ packetData: Data) throws {
    var index = 0

    let packetSize = UnsafePointer<UInt32>((packetData as NSData).bytes + index).pointee
    if packetData.count < Int(packetSize) {
        throw PacketInitializationError.notEnoughData
    }
    index += sizeofValue(packetSize)

    guard let t = PacketType(rawValue: UnsafePointer<Int8>((packetData as NSData).bytes + index).pointee) else {
        throw PacketInitializationError.invalidPacketType
    }
    packetType = t
    index += sizeofValue(t)

    id = Int(UnsafePointer<Int32>((packetData as NSData).bytes + index).pointee)
    index += MemoryLayout<Int32>.size

    let dataLength = Int(packetSize) - Packet.basePacketSize
    if dataLength > 0 {
        data = Data(bytes: UnsafePointer<UInt8>((packetData as NSData).bytes + index), count: dataLength)
    }
}
@traviskirton
Copy link
Contributor Author

@Aleph7 can you please help me with this error? i'm not clear on how to convert this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants