Avatar ·

How to generate UUID (GUID) in Swift for iOS?

Hi everyone! I'm new to iOS development and writing my first app in Swift. I need to generate a unique identifier for each user in my database. I've heard about UUID (universally unique identifier) or GUID — in short, I need a string like "123e4567-e89b-12d3-a456-426614174000" to store it in Core Data and send to the server. The problem is that I've searched through Apple's documentation but can't find a simple way to do this in Swift. Previously in Objective-C I used `CFUUIDCreate`, but in Swift it looks cumbersome and inconvenient. I tried writing something like: ```swift let uuid = CFUUIDCreate(nil) let uuidString = CFUUIDCreateString(nil, uuid) ``` But the compiler complains about incorrect types, and I get a bunch of errors. Please tell me how to