开发者

Automatically generated user id [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_开发技巧 Closed 11 years ago.

I am making an iphone application in which there is use of database. I want that whenever user put his or her information, there should be unique id no for each user. But this id no should generate automatically.

How can I do this..please help me.

Thanks alot.


You can get a unique ID by doing this:

NSString *uniqueID = [[NSProcessInfo processInfo] globallyUniqueString];
NSLog(@"%@", uniqueID);


Since you will be using SQLite for your database specific, you could make use of the auto increment present in SQLite for generating id automatically.


I prefer you to use uuid for each user. If you don't know about uuid check it may be this will fulfill your requirements.


see if this answer How to save a video taken from camera into sqlite database in iphone helps.
You can certainly take the unique Id generation from that link.


Have a look at the following example.

http://iosdevelopertips.com/general/create-a-universally-unique-identifier-uuid.html

this generated string + number unique string.

If you want only numbers then i guess you have to use current timestamp + some auto-generated random number string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜