Pregunta

Hello I can not save locally where I have to save an array of strings, I add that this array must be saved when closing the application for iOS and the reopening needs to be recharged, I found thousands of guides online but none are very specific, someone says use NSUserDefaults others say to use NSCoding but in both cases i can not recharge these data can anyone help me?

¿Fue útil?

Solución

To Save SMALL data - NSUserDefaults, NSCoding as suggested by other people or saving in plist also or else create a file in document directory and write the contents of array in that file.

LARGE Data- Save it in database using either sqlite or core data.

Choice depends on the requirement of the application and since you have not given the details of the data like maximum number of strings in the array, everyone can suggest you instead of telling a solution. Hope it helps :)

Otros consejos

You can use NSUserDefaults:

 [[NSUserDefaults standardUserDefaults] setObject:yourMutableArray forKey:@"Key"];

To get the value from NSMutableArray:

NSMutableArray *array = [NSMutableArray arrayWithArray:[[NSUserDefaults standardUserDefaults] objectForKey:@"Key"]];

Hope this is helpful.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top