수정 된 인코딩 된 UUID를 만드는 데 관심이 있지만 올바른 형식을 얻는 데 시간이 많이 걸리고 있습니다. 내가 현재 가지고있는 것은 알 수없는 이유 때문에 컴파일되지 않지만 놀랍도록도 놀이터에서 실행할 수 있습니다. 함수는 다음과 같습니다.Swift에서 수정 된 Base64 인코딩 UUID를 어떻게 만들 수 있습니까?
class func genID() -> String {
let uuid = NSUUID.UUID()
let data = NSData(bytes:&uuid, length:16)
let base64 = data.base64EncodedStringWithOptions(nil)
let options = NSStringCompareOptions.LiteralSearch
let result = base64
.stringByReplacingOccurrencesOfString("/", withString: "-", options: options, range: nil)
.stringByReplacingOccurrencesOfString("+", withString: "_", options: options, range: nil)
.stringByReplacingOccurrencesOfString("=", withString: "", options: options, range: nil)
return result
}
문제는 함수의 두 번째 줄에 표시됩니다. 데이터 값의 생성. 이상하게도 그 라인은 놀이터에서 작동합니다. 어떤 도움을 주시면 감사하겠습니다. 그래서 나는 무엇을 여기에서 놓치고 있냐?
미리 감사드립니다.
어쨌든 내가 –