У меня есть пользовательский тип:
open class HashTag: Equatable {
open var text: String
open var isRemovable: Bool
open var hasHashSymbol: Bool
open var configuration: HashtagConfiguration?
public init(word: String, withHashSymbol: Bool = true, isRemovable: Bool = true) {
self.text = word
self.isRemovable = isRemovable
self.hasHashSymbol = withHashSymbol
if hasHashSymbol {
self.text = "#" + text
}
}
public static func == (lhs: HashTag, rhs: HashTag) -> Bool {
return lhs.text == rhs.text
}
}
Я хочу перевести его в обычный массив String, а затем вернуть обратно. Например, для:
var tags = [
HashTag(word: "this"),
HashTag(word: "is"),
HashTag(word: "an"),
HashTag(word: "example")
]
Я хочу перевести на
var tagsTransferred = ["this","is","an","example"]
И обратно:
var tagsTransferred = ["this","is","an","example"]
на:
var tags = [
HashTag(word: "this"),
HashTag(word: "is"),
HashTag(word: "an"),
HashTag(word: "example")
]