Skip to main content

iOS Persisting Data

After completing the first PluralSight course and a working App, the first thing I noticed is that my app does not persist data. One of the main goals of this app is to help you track, over time, how many carbs you eat. You can enter data into the app, interact with that data, but once you close the app it all goes away. Thats not terrible useful, so I needed to find a way to store the data that is entered.

I know a little about iOS, and knew that CoreData was a framework that iOS has to store data within an app, so I searched on PluralSight for CoreData and found one course, Introduction to iOS for .NET Developers, by Jon Flanders. I thought, "Hey! That is me, awesome." First major difference in this course over others I have watched, he has broken it up into almost all 1 minute segments. That sort of makes sense here because he is mostly just relating .NET to iOS development, and assumes that once you know how to translate what you want to do in .NET to iOS that you can either figure out what question to ask next or figure it out on your own. Given that, I expect that I will return to this course more when I don't know what to ask Google. Disappointingly, this course did not go into CoreData in a significant way, so I wasn't able to get what I wanted at this time out of this course.

I went back and searched again using the term Core Data instead of CoreData. I found an entire course devoted to Core Data, Core Data Fundamentals, by Brice Wilson. Hopefully this course will provide the information I need to get started with saving data entered into my app. During the introduction, Brice talks about another course of his for consuming web services and storing smaller, more simple data in an app. It sounds like that might be a very good course to come back to if I need to have a web service feeding me data. He also talked about the demo app he will build in this course, which sounds like a great way for me to learn what I was looking for.

At first glance, even though he says it is not, the closest comparison I can make for CoreData is Entity Framework Code-First. Similar to EF, an Entity relates to a table and Attributes relate to a Column in that table. You can define relationships between Entities very much like a Database Foreign Key Constraint, including the ability to cascade delete.

Getting started creating an Entity is really very easy. You add a File and choose the Core Data -> Data Model file type. Then you can start adding Entities using the plus button. Adding Attributes is also as easy as a plus button. Looking at the properties of an attribute I see some things you would expect like data type and whether or not the Attribute is optional. I also found something I was not expecting, validation fields. Core Data has built into it the ability to define minimums and maximums. I will be curious to see how these work out, it can get tiresome always needing to do sanity checks in .NET because none of the objects you are working with are smart enough to know that they can't be below zero or before the year 1/1/1900, EF on a SQL 2005 Server, I am looking at you.

Comments

Popular posts from this blog

Converting a Large AngularJS Application to TypeScript Part 1

I work on a project that uses AngularJS heavily. Recently we wondered if using a preprocesser like CoffeeScript or TypeScript for our JavaScript would be beneficial. If our team is going to switch languages, we would need to be able to convert existing code over without much pain and we would have to find enough value in switching that it would be worth the conversion. I had read an article that stated that because TypeScript is a SuperSet of JavaScript, you could convert a plain JavaScript file to TypeScript by changing the extension to .ts and not much else would need to change. I wanted to test out this claim, so I took a file that I was familiar with, an Angular Controller, and tried to convert it to TypeScript to see how much effort it would take and then try to figure out where we would benefit from using TypeScript. This is what the controller JavaScript file looked like to start out with: ( function () { 'use strict' ; angular .module( 'app'...

Interns: Taking off the training wheels

My intern team has been working for several weeks now on our new website. We have already completed one deployment to production and are finalizing our second one. We started with a plan to release often adding small bits of functionality as we go and so far that plan has been working really well. We already feel like we have accomplished a lot because we have completed many of our project's requirements and should easily be able to complete the rest giving us time to do even more than just the original requirements. One of the things I have had some difficulty balancing has been how much to lead the interns and how much to let them figure out on their own. In deciding what our team process should be and how we should allocate our time, I think it was important for me to do more leading. I saw some deficiencies in how we were currently working and brought up some ideas for how we could address them. We had moved into spending all our time just working through stories and did not ...

My idea for Hearthstone to add more deck slots

Recently someone asked the Blizzard developers for more slots for decks in the game Hearthstone. The response was that they are talking about it and looking into it, but no decision has been made yet. One of the concerns over adding deck slots is that it could complicate the UI for Hearthstone and make it more difficult for new players to understand. I have what I think would be a good solution to add more deck slots without increasing the learning curve for the game much if at all. First I would take a look at the current selection screen for starting to play a game. It defaults to showing the decks that are custom built by the player if they have any custom decks, and there is an option to page over to the basic decks. This basic deck screen is perfect for how I would change this process. Instead of having 2 pages of decks, 1 for basic and 1 for custom, you would just see the select a Hero screen. Then once you selected the Hero you wanted, you would see all of the decks that ...