Skip to content

Instantly share code, notes, and snippets.

@suprie
Last active February 18, 2017 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suprie/49cf37ff346b158435c5f9f7dd3ef29c to your computer and use it in GitHub Desktop.
Save suprie/49cf37ff346b158435c5f9f7dd3ef29c to your computer and use it in GitHub Desktop.
Bad Smelled VC
// Converted with Swiftify v1.0.6242 - https://objectivec2swift.com/
class ViewController {
override func viewDidAppear(_ animated: Bool) {
var paths: [Any] = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)
var docsPath: String = paths[0]
var path: String = URL(fileURLWithPath: docsPath).appendingPathComponent("abc.sqlite").absoluteString
database = FMDatabase(path: path)
database.open()
var resultSet: FMResultSet? = database.executeQuery("SELECT * FROM products")
var listOfProducts = [Any]()
while resultSet?.next() {
var dictionary: [AnyHashable: Any]? = [
"code" : resultSet?.string(forColumn: "code"),
"name" : resultSet?.string(forColumn: "name"),
"id" : Int(resultSet?.int(forColumn: "id"))
]
listOfStation.append(dictionary)
}
var sortByFav = NSSortDescriptor(key: "favorite", ascending: false)
var sortByName = NSSortDescriptor(key: "name", ascending: true)
arrayOfStations = (listOfProducts as NSArray).sortedArray(using: [sortByFav, sortByName])
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "splash_bg"))
self.aTableView.backgroundColor = UIColor.clear
self.aTableView.reloadData()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment