Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to keep my data in a array-iphone sdk
    text
    copied!<p>I'm trying to create an application, and in that I'm receiving some contents from net and loading into and array, if I quit and run the app again i'm losing the data. How can I store the data in the app itself. Should I use some kind of database? If so which one and how can I implement that? I need to store only some string variables.</p> <p><strong>EDIT:</strong> My app is tabbar based app, and have two tabs. Loading the arrays in one tab and loading that array in a table in the other VC. once I load the array and move to the second tab, the table is loaded with the array. If i go back and add few more values and then if i check, the added datas is not displayed in the table. And also, when I quit the app the table lose all the values, I need to keep the values in the table, even after i quit the app. How can I do that? here is my code: in viewdidload:</p> <pre><code> NSUserDefaults *simplePlistDb = [NSUserDefaults standardUserDefaults]; [simplePlistDb setBool:YES forKey:@"isItWorking"]; [simplePlistDb setObject:alertList forKey:@"myArray"]; [simplePlistDb synchronize]; </code></pre> <p>in cellforrowatindexpath:-</p> <pre><code>NSUserDefaults *simplePlistDb = [NSUserDefaults standardUserDefaults]; BOOL flag = [simplePlistDb boolForKey:@"isItWorking"]; if (flag) { NSArray *myArray = [simplePlistDb objectForKey:@"myArray"]; for (NSString *str in myArray){ NSLog(@"Str:%@", str); [loadArray addObject:str]; } cell.textLabel.text = [loadArray objectAtIndex:indexPath.row]; } </code></pre> <p>Thank you.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload