flutter_flutter/shell/platform/darwin/common/buffer_conversions.mm
Mikkel Nygaard Ravn b97103b441 Flutter channels for iOS (#3470)
Flutter channels now also supported on iOS. Use FlutterMessageChannel or FlutterMethodChannel with binary/string/json/standard codecs.
2017-03-13 23:57:46 +01:00

21 lines
659 B
Plaintext

// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/shell/platform/darwin/common/buffer_conversions.h"
namespace shell {
std::vector<uint8_t> GetVectorFromNSData(NSData* data) {
if (!data.length)
return std::vector<uint8_t>();
const uint8_t* bytes = reinterpret_cast<const uint8_t*>(data.bytes);
return std::vector<uint8_t>(bytes, bytes + data.length);
}
NSData* GetNSDataFromVector(const std::vector<uint8_t>& buffer) {
return [NSData dataWithBytes:buffer.data() length:buffer.size()];
}
} // namespace shell