iphone - NSUserDefault to NSArray -


icstored value of 2 label in nsuserdefault, trought nsmutablearray.

nsuserdefaults *userdefaults = [nsuserdefaults standarduserdefaults];  // add bookmark nsmutabledictionary *bookmark = [nsmutabledictionary new]; [bookmark setvalue:author.text forkey:@"author"]; [bookmark setvalue:book.text forkey:@"book"]; [bookmarks addobject:bookmark];  // save (updated) bookmarks [userdefaults setobject:bookmarks forkey:@"bookmarks"]; [userdefaults synchronize]; 

now problem how retrieve values of nsuserdefault trought nsarray?

 nsuserdefaults *prefs = [nsuserdefaults standarduserdefaults];  self.dataarray = [prefs arrayforkey:@"bookmarks"];   nsstring *author =  ??   nsstring *book =  ?? 

nsstring * author = [self.dataarray objectforkey: @"author"]; nsstring * book = [self.dataarray objectforkey: @"book"]; 

this assumes saved array , re-loaded array nsuserdefaults. should error checking in code.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -