wireguard-apple/WireGuard/Extensions/String+Arrays.swift
Eric Kuck b306149222 Added validation before saving any tunnels
Signed-off-by: Eric Kuck <eric@bluelinelabs.com>
2018-08-15 17:34:16 -05:00

25 lines
528 B
Swift

//
// String+Arrays.swift
// WireGuard
//
// Created by Eric Kuck on 8/15/18.
// Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. All rights reserved.
//
import Foundation
extension String {
static func commaSeparatedStringFrom(elements: [String]) -> String {
return elements.joined(separator: ",")
}
func commaSeparatedToArray() -> [String] {
return components(separatedBy: .whitespaces)
.joined()
.split(separator: ",")
.map(String.init)
}
}