Core Data

Looking for a few newbie Core Data examples. I am trying to develop my own golf scorecard and want to use Core Data. Is this the best approach?

>newbie


How newbie are you? Why CoreData? How would you define your dev skills?

Tell a bit more of your app.


Is it to record scores of a single individual or for a whole golf members ?

If single, a simple file JSON) would be enough

How complex information do you want to collect ? With complex requestsn to filter information ?

The more complex data structure and requests, the more Core Data is appropriate

Do you want to save information on a server ?

Then even SQL database could be considered

So really all I am lookng to do is store:

Course name:

Date:

Hole 1

Club used

Distance

.....


But I would like to have this information available as a historial record of my game.

So a simple file, with a record as you described would be enough.

There will not be tens of thousands of records (I assume)

You would add a new record each time you record a new play.

A JSON file that you load at start, complement with new record and save back would likely do it.


But I would like to have this information available as a historial record of my game.

What do you mean beyond the date of the game ?


An idea: you could keep thumbnail photos (of the golf, of the play), in different files. That will make your app much more fun to use…

Just keep a photoNumber in the record to which you want to attach a photo. Use it as a way to reference photo file…

Cool idea! So my question is where would the JSON file be stored on the device? Just as a file in the filesystem? Or maybe would plists be a better solution?

hi,


KMT and Claude31 make good points. i'll add two others (BTW: i write code and i play a lot of golf)


  • you should decide whether you'll go with UIKit or SwiftUI. CoreData would be easier to work with in SwiftUI than with UIKit (JSON data would be about the same -- you'd write your JSON file or files to the Documents directory).
  • be sure you first test out recording on a physical scorecard what you think you'll want to enter into your phone while you're on the golf course. it will help you develop a good UI (e.g., if it takes you a long time to enter all your written data after the round, that's a lot of time you would have spent entering data during your round while your playing partners were waiting for you).


FWIW: i did a little MapKit-based app some time ago, to learn about MapKit. it was a basic "punch the button, record my GPS location in a list, and show me the distance from the last location." i also could pull up a map to trace the path from location to location. (MapKit is more manageable in UIKit, although that may change with WWDC2020 next week.)


it sounded interesting originally (and it has nothing specifically to do with golf), but measuring with GPS on the phone was never as good as measuring with my laser, so i stopped using it. and i kept forgetting to punch the button while i was on the course, since i was always focused on the next shot, not on the shot i just hit!


good luck, keep us updated, and hope that helps,

DMG

Core Data
 
 
Q