Various tweaks

This commit is contained in:
Neil Alexander 2023-02-08 22:56:37 +00:00
parent 0245b6db5e
commit 9ce78d5007
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944
9 changed files with 471 additions and 18 deletions

View file

@ -0,0 +1,20 @@
//
// Data.swift
// YggdrasilNetworkExtension
//
// Created by Neil on 15/11/2022.
//
import Foundation
extension Data {
/// This computed value is only needed because of [this](https://github.com/golang/go/issues/33745) issue in the
/// golang/go repository. It is a workaround until the problem is solved upstream.
///
/// The data object is converted into an array of bytes and than returned wrapped in an `NSMutableData` object. In
/// thas way Gomobile takes it as it is without copying. The Swift side remains responsible for garbage collection.
var mutable: Data {
var array = [UInt8](self)
return NSMutableData(bytes: &array, length: self.count) as Data
}
}