user8188972 user8188972 - 9 months ago 21
Swift Question

New UUID generated on each run

I have this code in my


let udid = UUID().uuidString

But each time I run the application I get a new generated
. How come?

I need the same ID for each user to be able to identify them so should I save this in a UserDefault or how should I do to uniquely identify a user even when the user restarts the application?

Answer Source

The tool for what you're trying to do is UIDevice.current.identifierForVendor. This returns exactly the kind of UUID you're describing (and is intended for this purpose).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download