Creating an application for the video gallery library. Need advice for storing data

I am not a complete newbie to iOS development, but I would appreciate some advice on how to set up the raw data file information for the video of the application I am making. I have created about 150+ videos that I use to help my students learn calculus. All are available for free at www.calcsuccess.org. As part of DIY iOS development, I want to create an iOS app that will allow students to quickly access them using a native iOS app. It will be a simple application that simply consists of one or two table views, and when students click on a cell in the table, they drag them into an AVPlayerView that shows a video hosted on my server. I ran the app and programmed three videos and tested them to make surethat segues are working correctly, and so on. If you are interested in the complete source code, you can find it here:

https://github.com/gmoalvarez/calcsuccess

Ok, now to my question:

Since there are hundreds of videos, each with a title and a URL, what is a good way to store and retrieve this information from the application?

For example, right now I have a basic structure for a video

struct Video {
    var title:String?
    var chapter:String?
    var section:String?
    var path:String?
    var url:NSURL?
    //  var quality:String
    var description:String? {
        return title
    }
}

      

The table cell is configured to take the video title and display it in the cell. Should I think about creating a CSV file with these fields and then learn how to parse it with Swift? Any other ideas?

Thanks in advance.

+3


source to share


2 answers


I would suggest a JSON file hosted on your website so you can edit it without re-submitting your application.

You can parse the JSON easily with Swift, it translates into a dictionary that you can iterate over and create new instances of your struct and put them into an array to be used with your UITableView.

I would suggest this tutorial for working with JSON in Swift: http://www.raywenderlich.com/82706/working-with-json-in-swift-tutorial



Alternatively, if you don't want to implement it this way, you can send a JSON file using Xcode app and download it. (Same as remote URL).

And finally, if you don't want to go that route, I would suggest Parse.com, it's a backend service with an awesome iOS API. You can manage your data at your end and even import XML or CSV files. There's a little learning curve there.

A remote JSON file or Parse.com will allow you to modify the data without resubmitting your application.

+2


source


You can use many different formats. I would probably use JSON as it is widely supported on a variety of hardware, easy to read by eye and not too verbose. iOS has an NSJSONSerialization class that will allow you to convert data between JSON and iOS container classes such as arrays.

There is also the ALAMOFire library, which is a lightweight Swift networking library that has built-in JSON support.



An array of dictionaries should work great for your application.

+2


source







All Articles