Now that we have covered the basics of Core Data, let's proceed with some code examples of how to use Core Data, where we use Core Data to store customer details in a Customer
table. The information we want to store is:
name
email
phone_number
address
age
Note
Do note that all attribute names must be in lowercase and should not have spaces in them. For example, we will use Core Data to store customer details mentioned earlier as well as retrieve, update, and delete the customer records using the Core Data framework and methods.
First, we will select File | New | File and then select iOS | Core Data:
Then, we will proceed to create a new Entity called Customer by clicking on the Add Entity button in the bottom left of the screen, as shown here:
Then, we will proceed to add in the attributes for our Customer entity and give them the appropriate Type, which can be String for attributes such as name or address and Integer 16 for age: