Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
//
// BlobDataResolver.swift
// sdk-xyo-swift
//
// Created by Kevin Weiler on 10/29/19.
//
import Foundation
import sdk_core_swift
public struct StringResolver: XyoHumanHeuristicResolver {
public init () {}
public func getHumanKey(partyIndex: Int) -> String {
return String(format: NSLocalizedString("String %d", comment: "String heuristic key"), partyIndex)
}
public func getHumanName (object: XyoObjectStructure, partyIndex: Int) throws -> String? {
let objectValue = try? object.getValueCopy()
if let blob = objectValue?.toByteArray() {
return String(bytes: blob, encoding: .utf8)
}
return nil
}
}
extension XyoBoundWitness {
public func resolveString(forParty: Int) -> String? {
let resolver = StringResolver()
XyoHumanHeuristics.resolvers[XyoSchemas.BLOB.id] = resolver
return resolver.getName(forParty: forParty, boundWitness: self)
}
}