CFUUIDCreateString()
is the recommended way of generating a Unique ID to use in your apps.
CFUUID is, as its name suggests, a UUID, which does have a chance of being the same, but in your individual case that chance is so insurmountably small that it'll likely never happen. See here:
http://en.wikipedia.org/wiki/Universally_unique_identifier#Random_UUID_probability_of_duplicates
In other words, only after generating 1 billion UUIDs every second for the next 100 years, the probability of creating just one duplicate would be about 50%. The probability of one duplicate would be about 50% if every person on earth owns 600 million UUIDs.
I don't think your app is going to be installed by every person on earth 600 million times. :)
In order to persist the UUID, you can save it in the keychain which is only cleared on iOS when the device is reset completely (it will persist between OS upgrades, but not full OS restores).
You shouldn't be using a generated UUID to keep track of a user. What if that user gets a new phone and wants to continue using your app? How do you know it's the same user on a new device?
That's what a user account is for. If you truly need to track the user and not the device, then you need to create a user account and have it stored on your backend service. No amount of UUID fudging is going to keep track of a user between devices. So many things can happen that might lead to a new UUID being created:
- user buys a new device
- loses their old device
- device gets damaged
- restores the device to factory settings
- sells the device to a someone else
If your answer to this is "we don't want to make an account for a user" then you obviously don't care that much about tracking them. UUIDs don't identify users. End of story.