如何在iOS中将数据类型转换为其他类型?

时间:2019-07-17 10:38:08

标签: ios arrays swift nsdata bytestream

我需要将typealiasCloudKit保存为类型Bytes的字段。

我能够成功地将typealias转换为类型Data的对象。我该如何将Data类型的对象转换为typealias的对象?

typealias NotificationIdentifiers = [[String]?]

var notificationIdentifiers: NotificationIdentifiers = [nil, [UUID().uuidString], [UUID().uuidString], [UUID().uuidString], [UUID().uuidString], [UUID().uuidString], [UUID().uuidString]]
let unsafeNIPointer: UnsafePointer<NotificationIdentifiers> = UnsafePointer<NotificationIdentifiers>(&notificationIdentifiers)
let unsafeNIBufferPointer: UnsafeBufferPointer<NotificationIdentifiers> = UnsafeBufferPointer<NotificationIdentifiers>(start: unsafeNIPointer, count: 1)
let dataNotificationIdentifiers: Data = Data(buffer: unsafeNIBufferPointer)

0 个答案:

没有答案