The easiest way to store a small amount of data on your device is to use NSUserDefaults. But this way you can save only property lists. The property list is a combination of 6 types of objects: NSNumber, NSString, NSArray, NSDictionary, NSDate, NSData. In your case, this is easy to do. For example, to save a new debt record, you can use the following method:
#define DEBTS_LIST_KEY @"listOfAllDebts" #define DEBTOR_NAME_KEY @"debtorName" #define DEBT_AMOUNT_KEY @"amountOfDebt" -(void) saveDebt:(CGFloat) debtAmount forName:(NSString *) debtorName {
To read the list of debts, you read something similar.
But I recommend you use basic data. It is more flexible, and you will not need to write all this code to manage your data (to edit existing records or to delete them). You can significantly expand your model, for example, when you want to keep a debt date. This is a link to a good tutorial.
source share