-1

I am having string that i want to convert UUID

my string is - > "43pszizx-0000-0000-0000-000000000000"

i want to convert this into UUID

i have tried this code

let contactUUID = "43pszizx-0000-0000-0000-000000000000"

if let uuid = UUID(uuidString: contactUUID) {
            moviesVC.conversationID = uuid
        }

but it always returns nil

is there any solution to convert this string to UUID, this string coming from API as a contactId

thanks in advance

1 Answers1

0

As per the doc

Returns nil if the string isn’t a valid UUID representation.

let contactUUID = "43pszizx-0000-0000-0000-000000000000"
//The string representation of a UUID, such as E621E1F8-C36C-495A-93FC-0C247A3E6E5F.

But the contactUUID doesn't seems to be matching with UUID representation so its always returning nil

vignesh
  • 994
  • 10
  • 12