Skip to main content

Group components - iOS

Create a component group

let group = UXComponents.createGroup(components: [passwordField, confirmPasswordField])

Add a component to a group

e.g., you want to add password component and card number component, you can accomplish this by adding:

group.addComponents(components: [securepasswordfield, confirmSecurePasswordField])

Check for data match

Data matching is about validating a user input

if group1.match() {
print("matched")
}

Create token out of grouped components

group.createToken(fieldKeys: ["PassKey0", "PassKey1", "PassKey2"], callBack: {
weavrResponse in
switch weavrResponse {
case let .success(data):
let encodedData = try? JSONEncoder().encode(data)
let jsonString = String(data: encodedData!, encoding: .utf8)
let sortedData = data.sorted(by: { $0.key < $1.key })
for (key, value) in sortedData {
print("Key: \(key) \(value ?? "")")
}
case let .failure(err):
print("\(err.code! ) \(err.message! ) \(err.body! )")
}
})