iphone - how to store array count in nsuserdefault -


how store long value in nsuserdefault

[[nsuserdefaults standarduserdefaults] setobject:[arrayvalue count] forkey:@"arraycountnumber"]; [[nsuserdefaults standarduserdefaults] synchronize]; 

or tried store [arrayvalue count] long value , this

[[nsuserdefaults standarduserdefaults] setobject:longvalue forkey:@"arraycountnumber"]; [[nsuserdefaults standarduserdefaults] synchronize]; 

nothing worked...

advance thanks...

your problem nsuserdefaults expects object type , should wrap scalar type nsnumber object:

[[nsuserdefaults standarduserdefaults] setobject:@([arrayvalue count]) forkey:@"arraycountnumber"]; [[nsuserdefaults standarduserdefaults] synchronize]; 

to retrieve value use following:

nsinteger count = [[nsuserdefaults standarduserdefaults] objectforkey:@"arraycountnumber"] integervalue]; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -