Skip to content

Crash in the extract function (remove ability to try deserialize unsupported types) #162

@akmarinov

Description

@akmarinov

I'm having an issue where Bluejay crashes in

screenshot 2018-08-21 15 39 07

Here's the call stack:

screenshot 2018-08-21 15 39 15

There's no console output for the crash, just that bad access.

My code is

struct AdvertisingData: Receivable {
    private(set) var partNumber: String
    private(set) var serialNumber: String


    init(bluetoothData: Data) throws {
        let serialNumberData: Data = try bluetoothData.extract(start: 0, length: 6)

    }
}

if I do

let partNumberData: Data = bluetoothData.subdata(in: 0..<0+6)

instead on my own, I'm able to get the sub data and use it to initialize my string to the correct value.

Any idea why you use .withUnsafeBytes { $0.pointee } and why it seems to crash with bad access?

Am I doing something wrong? I want to extract a string from a data that I receive.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions