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
Post a Comment