database - How to dynamically create an auto increment primary key for item id in iOS? -



database - How to dynamically create an auto increment primary key for item id in iOS? -

i have database storing list of items. want give id each of these items , fetch / update details of item db.

i have used appcoda's sqlite db manager , doing in mvvm way.

so, how maintain track of item id or auto increment id everytime? tried include id variable in viewdidload, but, gets reinitialized everytime app loads. primary key cant unique.

how resolve issue?

thanks

you can utilize nsuserdefaults keys, never gets destroyed until app uninstalled,

suppose have id 'int itemid = 1' can save in nsuserdefaults so,

[[nsuserdefaults standarduserdefaults] setvalue:[nsnumber numberwithint:itemid] forkey:@"id"]; [[nsuserdefaults standarduserdefaults] synchronize];

every time need write these 2 lines when want update id's count.

fetch value userdefauts

int itemid = [[[nsuserdefaults standarduserdefaults]valueforkey:@"id"]intvalue];

ios database sqlite primary-key viewdidload

Comments

Popular posts from this blog

php - How to pass multiple values from url -

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

database - php search bar when I press submit with nothing in the search bar it shows all the data -