Created
July 23, 2015 05:24
-
-
Save augusteo/17eac967db627276c572 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ViewController.swift | |
// RegionIndustryCSV | |
// | |
// Created by vic on 15/07/2015. | |
// Copyright (c) 2015 augusteo. All rights reserved. | |
// | |
import UIKit | |
import CSwiftV | |
import SwiftCSV | |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
var error:NSError? | |
let industryUrl = getCsvUrl(.Industry) | |
if let industryCsv = CSV(contentsOfURL: industryUrl, error: &error) { | |
println(industryCsv.headers) | |
} | |
} | |
// This func returns proper URL, guaranteed | |
func getCsvUrl(type: CsvType) -> NSURL { | |
switch type { | |
case .Region: | |
return NSURL(string: NSBundle.mainBundle().pathForResource("RegionData", ofType: "csv")!)! | |
case .Industry: | |
return NSURL(string: NSBundle.mainBundle().pathForResource("IndustryData", ofType: "csv")!)! | |
} | |
} | |
// Only two case | |
enum CsvType { case Region, Industry } | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment